title: Using dplyr mutate with conditions based on multiple columns
body: <p>Without NAs, the following code would work as intended: if the first row has any 2's in it, the new variable takes a value of 2; if not, I want to check if any of the values are 1; if not, check if any are 0; if not, then all must be NA. </p>
  
  <p>Once I add NAs into the data frame, it no longer works and I can't seem to figure out why:</p>
  
  <pre><code>V1 &lt;- c(NA,1,2,0,0)
  V2 &lt;- c(0,0,2,1,1)
  V3 &lt;- c(NA,0,2,1,0)
  
  V &lt;- cbind(V1,V2,V3)
  
  V &lt;- mutate(V,V4 = ifelse(V1 == 2|V2==2|V3==2, 2, 
  ifelse(V1==1|V2==1|V3==1, 1, ifelse(V1==0|V2==0|V3==0,0,NA))))
  </code></pre>
  
  <p>Intended output:</p>
  
  <pre><code>  V1 V2 V3 V4
  1 NA  0 NA  0
  2  1  0  0  1
  3  2  2  2  2
  4  0  1  1  1
  5  0  1  0  1
  </code></pre>
  
  <p>Actual output:</p>
  
  <pre><code>  V1 V2 V3 V4
  1 NA  0 NA NA
  2  1  0  0  1
  3  2  2  2  2
  4  0  1  1  1
  5  0  1  0  1
  </code></pre>