title: Combine several boolean variables in a data frame in R using a logical or
body: <p>Combine several boolean variables in a data frame using a logical or
  I have a data frame with several boolean variables that I am trying to combine.</p>
  
  <p>Here is an example dataset:</p>
  
  <pre><code>     temp1 temp2 temp3
  [1,] FALSE FALSE FALSE
  [2,]  TRUE  TRUE FALSE
  [3,] FALSE  TRUE  TRUE
  [4,]  TRUE  TRUE  TRUE
  [5,]  TRUE  TRUE FALSE
  [6,]  TRUE FALSE FALSE
  </code></pre>
  
  <p>I want to add a fourth variable "temp4" that is TRUE if either temp1 OR temp2 OR temp3 are TRUE. I have tried this:</p>
  
  <pre><code>temp$temp3&lt;-any(temp1,temp2)
  </code></pre>
  
  <p>But it coerces it into a list and creates a strange output.</p>
  
  <p>The closest I have found is this: <a href="https://stackoverflow.com/questions/19250544/combine-logical-vectors-in-list-using-logical-or">Combine logical vectors in list using logical or</a></p>
  
  <p>But this is for a list, not a data frame, and I'm not familiar with lists and can't figure out how to apply it to my problem.</p>
  
  <p>Thanks</p>