title: Setting value based on another column in dataframe
body: <p>I have the following data frame:</p>
  
  <pre><code>A  P(A)
  1  0.8
  0  0.7
  1  0.5
  1  0.8
  1  0.9
  0  0.7
  0  0.8
  </code></pre>
  
  <p>For all 0's in column <code>A</code>, I would like to calculate <code>1-P(A)</code>. This would give me the following dataset:</p>
  
  <pre><code>A  P(A)
  1  0.8
  0  0.3  ## 1 - 0.7
  1  0.5
  1  0.8
  1  0.9
  0  0.3  ## 1 - 0.7
  0  0.2  ## 1 - 0.8
  </code></pre>
  
  <p>I tried this but it doesn't give me the required output.</p>
  
  <pre><code>  for(i in nrow(results)) {
      if(results[i,1]==0) {
        results[i,2]&lt;- 1-results[i,2] 
      }
    }
  </code></pre>
  
  <p>How is this possible in R?</p>