title: Creating a new column based on two old columns in a data frame
body: <pre><code>data &lt;- data.frame(foo = c(0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1),
                     bar = c(1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0))
  </code></pre>
  
  <p>Hi, Here I am having a data frame with two columns foo and bar. I want to create a new column Complete, based on foo and bar data. </p>
  
  <ul>
  <li>If foo and bar is zero then complete should be 0. </li>
  <li>If foo is one and bar is 0 then complete should be one. </li>
  <li>If bar is 1 and foo is 0 then complete should be two. </li>
  </ul>
  
  <p>For example. </p>
  
  <pre><code>foo   bar complete
  0     0   0
  1     0   1
  0     1   2
  </code></pre>
  
  <p><strong>Edit:</strong></p>
  
  <p>If <code>foo==1</code> and <code>bar==1</code> then <code>NA</code>.</p>