[R] discarding 'levels'

hoopz zwhedbee at hotmail.com
Wed Oct 4 20:33:51 CEST 2006


Ok, so I am using read.table to read a .txt file and put it into a matrix. 
There are some values that are 'NA'.  If I use read.table with as.is =FALSE,
then some of the entries in the matrix return this:

> data[1,3]
[1]  0
Levels:  0  1  NA

and if I do 

> data[1,3]==0

it returns FALSE.  It's a zero, it's not false!


If I set as.is=TRUE, I don't get the levels problem, but in those entries
where I did get the levels problem, this happens:

> data[1,3]
[1] " 0"

This time, it keeps it as a string.  I can use as.numeric to fix it now, but
I'm just curious as to why this happens.


Thanks
-- 
View this message in context: http://www.nabble.com/discarding-%27levels%27-tf2384152.html#a6645474
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list