title: Is there an R function to combine multiple columns from the same data frame into the same column?
body: <p>At the moment I have four columns that need to be combined/merged into one column. Each row will either have four &quot;0&quot;s OR there will be one &quot;1&quot; with three &quot;0&quot;s.</p>
  <p>This is what the data frame looks like right now:</p>
  <pre><code>id     L1_Correct    L2_Correct     L3_Correct    L4_Correct
   1          0             0              0             1
   2          1             0              0             0
   3          0             1              0             0
   4          1             0              0             0
   5          0             0              1             0
  </code></pre>
  <p>This is what I want the dataframe to look like:</p>
  <pre><code> id     L1_Correct    L2_Correct     L3_Correct    L4_Correct    Combined__L_Accuracy   
   1          0             0              0             1             1
   2          1             0              0             0             1
   3          0             0              0             0             0
   4          1             0              0             0             1
   5          0             0              0             0             0
  </code></pre>
  <p>I tried using the paste function and the unite function on separate occasions: I.e,</p>
  <pre><code>L_Data$Combine_L_Accuracy &lt;- paste(L_Data$L1_Correct, L_Data$L2_Correct, L_Data$L3_Correct, L_Data$L4_Correct)
  
  L_Data_all &lt;- L_Data %&gt;% unite(Combine_L_Accuracy, L1_Correct, L2_Correct, L3_Correct, L4_Correct, na.rm = TRUE, remove = TRUE) 
  </code></pre>
  <p>L_Data_all</p>
  <p>But they both provided me with an outcome like: 0_0_0_0
  I only need 1 value in the last column either a 0 or 1 based on values across the four columns.</p>