On Fri, 3 Nov 2006, Herve Pages wrote: > > df5 <- data.frame(toto=c("a","bb"), titi=c(9,999)) > > as.matrix(df5) > toto titi > 1 "a" " 9" > 2 "bb" "999" > ... > 2) the questionable decision to do this conversion using 'format' > (leading to the addition of unnecessary white space) and not > simply 'as.character'
It is possible that this decision was made because one use of as.matrix(mixed-mode-data-frame) was for printing data.frames and format(numberic-column) would line up the decimal points and make one scientific-notation/or-not decision for the entire column. (Splus3.4, c. 1996, printed data.frames with print(as.matrix(x)), but by 1999 Splus4.7 was using print(format(x)).) R> df6<- data.frame(toto=c("a","bb","ccc"), titi=c(.9e-20,.99999,999.9)) R> as.matrix(df6) toto titi 1 "a" "9.0000e-21" 2 "bb" "9.9999e-01" 3 "ccc" "9.9990e+02" R> df7<-data.frame(toto=c("a","bb","ccc"), titi=c(.9,.99999,999.9)) R> as.matrix(df7) toto titi 1 "a" " 0.90000" 2 "bb" " 0.99999" 3 "ccc" "999.90000" Once such a decision is made it is hard to change things, especially when the benefit is slight. ---------------------------------------------------------------------------- Bill Dunlap Insightful Corporation bill at insightful dot com 360-428-8146 "All statements in this message represent the opinions of the author and do not necessarily reflect Insightful Corporation policy or position." ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel