title: Count columns satisfying a multiple OR statement and an AND statement
body: <p>I would like to count the number of columns, in each row of a data frame, that satisfy a multiple OR condition.</p>
  
  <p>In the first 100 columns of my data frame I have "codes" (that are integers). Let's say I want the number of columns where the value is either 111,112 or 113.</p>
  
  <p>I tried </p>
  
  <pre><code>rowSums(mydata[,1:100]==111 | mydata[,1:100] == 112 | mydata[,1:100] == 113)
  </code></pre>
  
  <p>This works, but as I have a lot of codes to check I would prefer to use an %in% statement like </p>
  
  <pre><code>rowSums(mydata[,1:100] %in% c(111,112,113))
  </code></pre>
  
  <p>but this does not work and I haven't been able to find the appropriate syntax. (I looked at other questions about %in% but I didn't find any answer that solved my problem.)</p>
  
  <p>The second part of the question is, how to add an AND condition on other columns ? Something like</p>
  
  <pre><code>rowSums(mydata[,1:100] %in% c(111,112,113) &amp; mydata[,101:200] %in% c("a","b","c"))
  </code></pre>
  
  <p>?</p>