title: How can I create a new variable based on conditions in R
body: <p>I am trying to create a new variable based on some conditions.</p>
  
  <p>My data looks like</p>
  
  <pre><code>a   b
  1   NA
  2   3
  3   3
  NA  2
  NA  NA
  </code></pre>
  
  <p>What I want is a variable <code>c</code> such that</p>
  
  <ul>
  <li><p>when <code>a</code> is not <code>NA</code>, <code>b</code> is <code>NA</code>, <code>c = a</code></p></li>
  <li><p>when <code>a</code> is <code>NA</code>, <code>b</code> is not <code>NA</code>, <code>c = b</code></p></li>
  <li><p>when <code>a</code> is <code>NA</code>, <code>b</code> is <code>NA</code>, <code>c = NA</code></p></li>
  <li><p>when <code>a</code> is not <code>NA</code>, <code>b</code> is not <code>NA</code>, and <code>a == b</code>, <code>c = a</code></p></li>
  <li><p>when <code>a</code> is not <code>NA</code>, <code>b</code> is not <code>NA</code>, and <code>a != b</code>, <code>c = "multiple_values"</code></p></li>
  </ul>
  
  <p>How can I do this?</p>
  
  <p>It seems like <code>ifelse()</code> can't do what I want.</p>