[R] convert data.frame to matrix -> NA factor problem

syrvn mentor_ at gmx.net
Wed Jul 14 16:58:06 CEST 2010


Hi,

I used str() on my data set:

$ X1            : num  1 1 0 1 1 1 1 1 1 1 ...
$ X2            : num  0 1 0 2 1 2 0 2 2 0 ...
$ X3            : Factor w/ 4 levels "0","1","2","NA": 2 1 3 1 1 1 1 1 1 3
...
....


The difference to your str() output is that in your case NA columns are
"num" columns
and in my case they are Factors. That's prob. why it replaces the NAs with 4
after
applying data.matrix.

I use the package xlsx to read the data in as an excel file.

Cheers
-- 
View this message in context: http://r.789695.n4.nabble.com/convert-data-frame-to-matrix-NA-factor-problem-tp2288828p2288887.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list