title: If Statement - Condition Length Greater Than 1
body: <p>I have two columns (<code>df$Z</code> and <code>df$A</code>)</p>
  
  <p>I basically want to say: if df$Z is less than 5, then fill <code>df$A</code> with an <code>NA</code> and if not then leave <code>df$A</code> alone. I've tried these things but am not sure where I'm going wrong or what the error message means.</p>
  
  <pre><code>if(df$X&lt;5){df$A &lt;- NA}
  </code></pre>
  
  <p>Error: </p>
  
  <blockquote>
    <p>In if (df$X &lt; 5) { :  the condition has length > 1 and only the first element will be used</p>
  </blockquote>
  
  <p>I also tried to do something more like this.</p>
  
  <pre><code>for(i in dfX){
  if(df$X&lt;5){
  df$A &lt;- "NA"
   }
  }
  </code></pre>