Re: [Rd] man page for as.matrix for data frames outdated?

From: Bill Dunlap <>
Date: Fri 03 Nov 2006 - 19:52:21 GMT

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

 "All statements in this message represent the opinions of the author and do  not necessarily reflect Insightful Corporation policy or position." mailing list Received on Sat Nov 04 06:55:00 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 03 Nov 2006 - 20:30:35 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.