title: What's wrong with this for/if loop? (R)
body: <p>There are two columns.
  In a new column, I want it to <em>randomly</em> add or subtract the other two columns:</p>
  
  <pre><code>for (i in 1:nrow(data) {
    if (round(runif(1, 1,2),0) == 1) {
      data$p_p2= data$p[i] + data$p2[i]
  } else {
    data$p_p2  = data$p[i] - data$p2[i]
  }
  }
  </code></pre>
  
  <p>e.g.,</p>
  
  <pre><code>  p  p1  p_p2 *goal*
  
    1  3   -2
    3  3   6
    5  2   7
  </code></pre>
  
  <p>Thanks</p>