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

From: Martin Maechler <maechler_at_stat.math.ethz.ch>
Date: Sat 04 Nov 2006 - 10:27:33 GMT

>>>>> "Herve" == Herve Pages <hpages@fhcrc.org> >>>>> on Fri, 03 Nov 2006 10:50:10 -0800 writes:

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

yes, indeed, and I was missing them up partly.

    Herve> 1) A documentation problem:

    Herve> "The method for data frames will convert any
    Herve> non-numeric/complex column into a character vector
    Herve> using 'format'"

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

    Herve> toto titi
    Herve> 1 "a"  "  9"
    Herve> 2 "bb" "999"

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

Indeed, and I now agree that the documentation is more wrong than I first acknowledged. I'm changing it currently.

    Herve> 2) the questionable decision to do this conversion using 'format'
    Herve> (leading to the addition of unnecessary white space) and not
    Herve> simply 'as.character'

as Bill remarked,
- there were good reasons pro such a decision, - to change such decisions without necessity is a problem for   back-compatibility

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

yes. Part of it was my mistake; sorry.

Best regards to Seattle,
Martin



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Sun Nov 05 03:24:58 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 - 17:30:34 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.