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

From: Herve Pages <hpages_at_fhcrc.org>
Date: Fri 03 Nov 2006 - 18:50:10 GMT

Hi Martin,

Thanks for the answer!
OK I can use data.matrix to convert a data frame to a numeric matrix but that's another story. Basically I'm reporting 2 problems with 'as.matrix' when applied to a data frame:

  1. A documentation problem:

    "The method for data frames will convert any

     non-numeric/complex column into a character vector
     using 'format'"

> df5 <- data.frame(toto=c("a","bb"), titi=c(9,999))
> as.matrix(df5)
      toto titi
    1 "a" " 9"
    2 "bb" "999"

     As I said, it seems to be the other way around: it's not the
     "non-numeric" column that is converted to a character vector,
     it's the "numeric" column.

2) the questionable decision to do this conversion using 'format'

   (leading to the addition of unnecessary white space) and not    simply 'as.character'

BTW your mailer seems to do some strange reformatting to the output of my code snippets making it hard to see the "formatting" problem that I'm trying to show.

Cheers,

H.



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Sat Nov 04 05:52:07 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 Sat 04 Nov 2006 - 16:30:33 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.