title: calculate count of values that satisfy two condition in r
body: <p>I'm new to R and have a large data set where I need to check to see if one of the two values exceeds a threshold; if it does, I need to count it, and if it doesn't I ignore that value. </p>
  
  <p>I have to iterate through several columns, but I run into the issue where my if statement only checks the first value. A simple example would have the columns <code>id</code>, <code>val1</code>, <code>val2</code>, <code>val3</code>. If <code>val1</code> or <code>val2</code> are greater than a threshold, then I would count <code>val3</code> otherwise ignore. My data set is called <code>data</code>.</p>
  
  <pre><code>id val1 val2 val3
  1  .4    4    10
  2   5    5    11
  3   2    2    1
  4   6    1    10
  5   2    100  4
  </code></pre>
  
  <p>My code is:</p>
  
  <pre><code>if(data$val1 &gt; 5 | data$val2 &gt; 5){sum(data$val3&gt;5)}
  </code></pre>
  
  <p>The issue is that it only checks the first row. How can I iterate through every row?</p>