>From TFM of read.table: as.is: the default behavior of 'read.table' is to convert character variables (which are not converted to logical, numeric or complex) to factors. The variable 'as.is' controls the conversion of columns not otherwise specified by 'colClasses'. Its value is either a vector of logicals (values are recycled if necessary), or a vector of numeric or character indices which specify which columns should not be converted to factors.
You may have some blanks in the third column. Factor levels whose character representation happens to be a numeral don't necessarily compare equal to the integer with the same character representation (if you get my drift...). You can use "as.numeric", but better would be to use colClasses in read.table. Regards, Mike On 10/4/06, hoopz <[EMAIL PROTECTED]> wrote: > > 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. > > ______________________________________________ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Regards, Mike Nielsen ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.