Possible Duplicate:
R filtering out a subset
I have an R dataset. In this dataset, I wish to create a crosstable using the package gmodels
for two categorial variables, and then run a chisq.test
on them.
The two variables are witness
and agegroup
. witness
consists of observations that has value 1,2 and 9. agegroup
consists of values 1,2.
I wish to exclude values if witness=9
, or/and a 3rd variable EMS=2
from the table but I am not sure how to proceed.
library(gmodels)
CrossTable (mydata$witness, mydata$agegroup)
chisq.test (mydata$witness, mydata$agegroup)
...so my question is, how can i do the above with the conditions that witness!=9
and EMS!=2