title: R data management: Aggregating multiple variables into newly generated variable based on multiple conditions from other variables
body: <p>I'm a brand New R user, this is my first attempt at conditional statements - and first time posting an online question - so please bear with me. </p>
  
  <p>I'm managing data from a questionnaire survey into something that can be analyzed. As a rookie mistake, I've been using the question form "tick all that apply" frequently - obtaining a matrix with one column per alternative answer. I am trying to combine these by conditional logic into a single column per question. </p>
  
  <p>Using one of these matrices as example, my dataframe BS looks like this: </p>
  
  <pre><code>ID Q29_ Q29_ Q29_3 Q29_4
  1  1    NA    NA    1
  2  NA   1     1     1 
  3  1    NA    NA    NA 
  4  NA   1    NA    NA
  […]
  </code></pre>
  
  <p>Using following code</p>
  
  <pre><code>  BS1 &lt;- BS %&gt;%
    mutate(WaterOutdoors = c("", "Yes")[(Q29_2 %in% c("Outdoors") | 
                                       Q29_3 == "Outdoors" |
                                       Q29_4 == "Outdoors")+1])
  </code></pre>
  
  <p>I get </p>
  
  <pre><code>ID Q29_ Q29_ Q29_3 Q29_4 WaterOutdoors
  1  1    NA   NA     1          Yes
  2  NA   1     1     1          Yes
  3  1   NA    NA    NA          
  4  NA  NA    NA    NA
  5  NA   1    NA    NA         Yes
  […]
  </code></pre>
  
  <p>I would like to add a "No"-option to the "WaterOutdoors" variable for those rows who have ticked off Q29_1 (Q29_1="1") and <em>did not</em> tick of any of the following (Q29_2=NA, Q29_3=NA, Q29_4=NA), and at <em>the same time</em> leave "WaterOutdoors" either empty or NA if <em>none</em> of the Q29_1:_4 have been ticked of. </p>
  
  <p>I have tried  </p>
  
  <pre><code>BS1$WaterOutdoors &lt;- with(BS1, ifelse(Q29_1 %&gt;% c("InStable") &amp; 
                                      is.na(Q29_2) &amp;
                                      is.na(Q29_3) &amp;
                                      is.na(Q29_4),
                                    "No",""))
  </code></pre>
  
  <p>hoping to get </p>
  
  <pre><code>ID Q29_ Q29_ Q29_3 Q29_4 WaterOutdoors
  1  1    NA   NA     1          Yes
  2  NA   1    1      1          Yes
  3  1    NA   NA     NA         No
  4  NA   NA   NA     NA         NA
  5  NA   1    NA     NA         Yes
  […]
  </code></pre>
  
  <p>but rather got the error-message: "Error in Q29_1 %>% c("InStable") &amp; is.na(Q29_2) : 
    operations are possible only for numeric, logical or complex types"</p>
  
  <p>My logic is obviously flawed, any input on how I <em>should</em> have gone about doing this would be greatly appreciated! </p>