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

Herve Pages hpages at fhcrc.org
Fri Nov 3 19:50:10 CET 2006

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.



More information about the R-devel mailing list