From bill at insightful.com  Fri Nov  3 20:52:21 2006
From: bill at insightful.com (Bill Dunlap)
Date: Fri, 3 Nov 2006 11:52:21 -0800 (PST)
Subject: [Rd] man page for as.matrix for data frames outdated?
In-Reply-To: <454B8F62.3030205@fhcrc.org>
References: <454AC989.1040002@fhcrc.org>
	<17738.64809.495879.29680@stat.math.ethz.ch>
	<454B8F62.3030205@fhcrc.org>
Message-ID: <Pine.GSO.4.56.0611031135130.12265@durian.statsci.com>

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."



[Rd] man page for as.matrix for data frames outdated?
Bill Dunlap