title: Keeping rows if any column matches one of a set of values
body: <p>I have a simple question about subsetting using R; I think I am close but can't quite get it. Basically, I have 25 columns of interest and about 100 values. Any row that has ANY of those values in at one of the columns, I want to keep. Simple example:</p>
  
  <pre><code>Values &lt;- c(1,2,5)
  
  col1 &lt;- c(2,6,8,1,3,5)
  col2 &lt;- c(1,4,5,9,0,0)
  col3 &lt;- c('dog', 'cat', 'cat', 'pig', 'chicken', 'cat')
  df &lt;- cbind.data.frame(col1, col2, col3)
  
  df1 &lt;- subset(df, col1%in%Values)
  </code></pre>
  
  <p>(Note that the third column is to indicate that there are additional columns but I don't need to match the values to those; the rows retained only depend upon columns 1 and 2). I know that in this trivial case I could just add </p>
  
  <pre><code>| col2%in%Values
  </code></pre>
  
  <p>to get the additional rows from column 2, but with 25 columns I don't want to add an OR statement for every single one. I  tried</p>
  
  <pre><code> file2011_test &lt;- file2011[file2011[,9:33]%in%CO_codes] #real names of values
  </code></pre>
  
  <p>but it didn't work. (And yes I know this is mixing subsetting types; I find subset() easier to understand but I don't think it can help me with what I need?)</p>