BUG in format()? (PR#383)

Kurt Hornik Kurt.Hornik@ci.tuwien.ac.at
Wed, 22 Dec 1999 11:28:42 +0100 (CET)


>>>>> Prof Brian D Ripley writes:

> On Tue, 21 Dec 1999 jens.oehlschlaegel-akiyoshi@mdfactory.de wrote:
>> 
>> 
>> In RW0.651 and RW0.901,
>> I discovered some unexpected behaviour when I used as.matrix.data.frame()
>> 
>> > matrix('"', 2, 2)
>> [,1] [,2]
>> [1,] "\"" "\""
>> [2,] "\"" "\""
>> > unclass(as.data.frame(matrix('"', 2, 2)))
>> $V1
>> [1] "\"" "\""
>> 
>> $V2
>> [1] "\"" "\""
>> 
>> attr(,"row.names")
>> [1] "1" "2"

> Now that is unexpected. The components should be factors. The code
> converting matrices to data frames is not behaving as the prototype,
> and that explains the rest, as the prototype gets the answer you would
> expect. The rule is supposed to be that adding a matrix is equivalent to
> adding each column in turn (White Book, page 59, and the S code).

> I am not aware of any documentation of an R difference here (but I may
> be wrong, although I checked the FAQ), and we need to fix either
> as.data.frame.matrix or as.matrix.data.frame.  I will argue for the
> first.

Definitely.  The docs say that it (in fact, as.data.frame()) will do
type conversion, but it simply does not.

-k
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._