[R] subset

Uwe Ligges ligges at statistik.uni-dortmund.de
Fri Sep 13 10:56:20 CEST 2002


Ngayee J Law wrote:
> 
> 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?

Works for me on R-1.5.1, NT4.0.

Do you have z defined anywhere else?
If not and your version is recent: Can you provide an example?
Please, tell us your version of R and your OS as well. 

Uwe Ligges
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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