[R] weird question about lm() and data.frame

Guojun Zhu shmilylemon at yahoo.com
Fri May 5 07:17:37 CEST 2006


I am still battling with my project :(

I have a line like this

lm(month.model$next.ret~.,month.model,na.action=na.omit)

month.model is a data frame with lots of columns.  One
of them is "Oth", a dummy variable. I checked
month.model, there are two rows with number 1 and
others are either 0 or NA.  the two rows with Oth==1
have no NA.  I have totally about 900 rows.  But after
the regression, the Oth's coefficient is NA.  I do not
understand.  

Another issue is also about NA.  I offen use something
like "model[model$Oth==1,]", but it will not only
gives rows with oth==1, but also gives some rows with
all item as NA.  I then changed this into "
month.model[(month.model$Oth==1)&(!is.na(month.model$next.ret)),]"
and it gives the same result.  Finally I change it
into
"
month.model[(month.model$Oth==1)&(!is.na(month.model$Oth)),]"
and it works.  next.ret is a column for sure.  Can
anyone explain this to me?




More information about the R-help mailing list