title: R Function Find First Non-True in data frame
body: <p>I'm trying to find the first non-True (minus 1) for each row in a data frame.</p>
  <p>The result looks like this:</p>
  <pre><code>     V1    V2    V3    V4    V5 true
  1  TRUE FALSE FALSE  TRUE FALSE    1
  2  TRUE FALSE FALSE FALSE    NA    1
  3 FALSE FALSE FALSE FALSE  TRUE    0
  4 FALSE FALSE FALSE FALSE FALSE    0
  5 FALSE FALSE FALSE FALSE FALSE    0
  6 FALSE FALSE FALSE FALSE FALSE    0
  </code></pre>
  <p>The following code works, but takes too long due to looping. I'm not sure how to properly execute this using an apply statement.</p>
  <pre><code>#Create the function to find the first non-true
  min.true &lt;- function(x,i){
  min(which(x[i,]==!TRUE))-1
  }
  
  #Create a null column
  match.words$true &lt;- NA
  
  #Find the first non true in each row
  for (i in 1:nrow(match.words)){
  match.words$true[i] &lt;-  min.true(match.words,i)  
  
  }
  </code></pre>
  <p>Essentially I'm looking for something like this that would run faster</p>
  <pre><code>match.words$true &lt;- apply(match.words, 1, min.true(match.words))
               
  </code></pre>