title: Using if else to filter a tibble in R
body: <p>I'm trying to use an if else statement and the filter function to clean some data and get rid of values that are too high.</p>
  <p>This is an example of my tibble:</p>
  <pre><code>animals.data &lt;- c(&quot;pig&quot;,99,&quot;dog&quot;,30,&quot;pig&quot;,20,&quot;pig&quot;,200,&quot;dog&quot;,120,&quot;dog&quot;,40)
  
  animals &lt;- matrix(animals.data, nrow=6,ncol=2, byrow=TRUE)
  
  colnames(animals) &lt;- c(&quot;Variable&quot;,&quot;Value&quot;)
  
  </code></pre>
  <p>This is the code I'm trying to run:</p>
  <pre><code>animals &lt;- animals %&gt;% 
    filter(
      if (animals$Variable==&quot;pig&quot;) {
        animals$Value &lt; 100 
      } else {
        animals$Value &lt; 140
      }
    )
  </code></pre>
  <p>This is the error I keep getting:</p>
  <pre><code>the condition has length &gt; 1 and only the first element will be used
  </code></pre>
  <p>I'm wanting to iterate through both columns in the tibble. Thank you in advance! I also welcome if you also have any comments about bad practice things I'm doing, I'm a beginner.</p>