[R] subset

Ngayee J Law Ngayee.Law at celeradiagnostics.com
Fri Sep 13 03:17:04 CEST 2002


Dear list,

I have a simple question. If I need to run linear regression on a subset of
the dataset, will
the following two commands give the same output:

lm(y ~ as.factor(x1) + as.factor(x2), data, subset = z==Z[1])

and

lm(y ~ as.factor(x1) + as.factor(x2), data[data$z==Z[1],] )


I have got different results running the two commands. Am I missing
something here, or it
there a bug on the option subset?

Thanks for the help!

- Jackie




-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list