title: Recode multiple response variables into one in R
body: <p>I have a data frame that looks like this:</p>
  
  <pre><code>Df &lt;- data.frame(
         mn = c(1,0,1,1,1,1,0), 
         bc = c(1,1,1,0,0,1,1),
         bn = c(0,0,1,1,0,1,0))
  </code></pre>
  
  <p>I want to recode these into a new variable. </p>
  
  <p>I tried something like this </p>
  
  <pre><code>Df$Var[which(Df$mn %in% 1)] &lt;- "mn"
  Df$Var[which(Df$bc %in% 1)] &lt;- "bc"
  Df$Var[which(Df$bn %in% 1)] &lt;- "bn"
  </code></pre>
  
  <p>This works but I don't get 5 mns, 5 bcs and 3 bns. It looks like one command overrides the other. I know something like this is possible in SPSS. It combines them automatically. My question is how can I do this without any overriding in R.</p>