title: Replace rows in a data frame based on criteria
body: <p>I have the following data frame</p>
  
  <pre><code>   id f1 f2
  1  a  1  3
  2  b  3  5
  3  c  4  7
  </code></pre>
  
  <p>I would like to replace all rows which have f1>3 with a row (id = x, f1 = 0, f2 = 0)
  So the above would map to </p>
  
  <pre><code>   id f1 f2
  1  a  1  3
  2  b  3  5
  3  x  0  0
  </code></pre>
  
  <p>But when I tried </p>
  
  <pre><code>replace(x,which(x$f1&gt;3),data.frame(id = 'x',f1=0,f2=0))
  </code></pre>
  
  <p>It didn't do it right, it gave</p>
  
  <pre><code>   id f1 f2
  1  a  1  x
  2  b  3  x
  3  c  4  x
  Warning message:
  In `[&lt;-.data.frame`(`*tmp*`, list, value = list(id = 1L, f1 = 0,  :
    provided 3 variables to replace 1 variables
  </code></pre>
  
  <p>Could someone suggest a way to do this at scale? Thanks.</p>