Hi Gabor,

in your example X is not a factor, I don't know if this matters.
 > x <- head(letters)
 > is.factor(x)
[1] FALSE

Here is an example of my problem:
The file C://test.txt contains
id|bmicat|cat
1 |NA |.
2 |<23 |a
3 |>28 |b
4 |NA |c

 > 
test<-read.table("C://test.txt",header=T,sep="|",na.strings=c("NA","."),colClasses=c(id="factor",
 
bmicat="factor", cat="factor"))
 > summary(test)
 id     bmicat    cat  1 :1   <23 :1   a   :1 2 :1   >28 :1   b   :1 3 
:1   NA  :2   c   :1 4 :1                 NA's:1 > levels(test$bmicat)
[1] "<23 " ">28 " "NA "
 > levels(test$cat)
[1] "a" "b" "c"
 >

I tried the to read this file with out the cat variable and read.table() 
recognized the "NA" properly. Adding the cat variable and its other code 
for the missing (".") seems to confuse read.table().

Thanks for your help.
Peter

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to