title: Excluding values in cross table
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/10367120/r-filtering-out-a-subset">R filtering out a subset</a>  </p>
  </blockquote>
  
  
  
  <p>I have an <strong>R</strong> dataset. In this dataset, I wish to create a crosstable using the package <code>gmodels</code> for two categorial variables, and then run a <code>chisq.test</code> on them.
  The two variables are <code>witness</code> and <code>agegroup</code>. <code>witness</code> consists of observations that has value 1,2 and 9. <code>agegroup</code> consists of values 1,2. 
  I wish to exclude values if <code>witness=9</code>, or/and a 3rd variable <code>EMS=2</code> from the table but I am not sure how to proceed.</p>
  
  <pre><code>library(gmodels)
  CrossTable (mydata$witness, mydata$agegroup)
  chisq.test (mydata$witness, mydata$agegroup)
  </code></pre>
  
  <p>...so my question is, how can i do the above with the conditions that <code>witness!=9</code> and <code>EMS!=2</code></p>