[R] Problems making subsets with [] or "subset"

gaiarrido gaiarrido at usal.es
Fri Jan 28 18:27:00 CET 2011


Hi,
I'm trying to make a model in order to know wich factors got´s influence in
the intensity of a infection, but just in the individuals who's got this
infection. In my data I've got a variable called "prevalence" with 2 levels:
1.- Infected individual
0.- Non infected

So what i'm trying to do is a subset in a model like this,
model<-aov(intensity~ageandsex*month*zone*year,subset=(prevalence=="1"))
Is a correct way?
I prefer to make the subsets with [], but doesn't work, why

> model<-aov(hemogregarinas~edadysexo*mes*zona*ano,[prevalencia=="1"])
Error: inesperado '[' en
"model<-aov(hemogregarinas~edadysexo*mes*zona*ano,["

And finally, look at this, i don't know why I get different results
> summary(hemogregarinas[prevalencia=="1"])
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
   1.00    5.00    9.00   15.94   19.00  173.00 
> summary(hemogregarinas,subset=(prevalencia=="1"))
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
   0.00    4.00    9.00   14.92   18.00  173.00 

Thanks very much

-----
Mario Garrido Escudero
PhD student
Dpto. de Biología Animal, Ecología, Parasitología, Edafología y Qca.
Agrícola
Universidad de Salamanca
-- 
View this message in context: http://r.789695.n4.nabble.com/Problems-making-subsets-with-or-subset-tp3245007p3245007.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list