title: Getting index of first occurrence of a value in every column of a matrix
body: <p>If I have a single vector, I can get the 1st occurrence which is below a value:</p>
  
  <pre><code>test &lt;- c(0.5,0.8,0.1,0.08,0.06,0.04)
  which(test&lt;0.1)[1]    
  </code></pre>
  
  <p>which correctly gives the answer as <code>4</code>.  However, how do I get the first occurrence within each column of a matrix, such as the furst occurrence below 5 in the following 2 column matrix:</p>
  
  <pre><code>test2 &lt;- matrix(c(5,8,3,4,7,5,6,2),ncol=2)
  </code></pre>
  
  <p>Using <code>apply</code> with <code>which</code> returns a list:</p>
  
  <pre><code>&gt; apply(test2&lt;5,2,which)
  [[1]]
  [1] 3 4
  
  [[2]]
  [1] 4
  </code></pre>
  
  <p>while using <code>apply</code> with <code>which.min</code> returns <code>1</code> for all columns:</p>
  
  <pre><code>&gt; apply(test2&lt;5,2,which.min)
  [1] 1 1
  </code></pre>
  
  <p>whereas, what I want should just return <code>[1] 3 4</code> - am I missing something obvious?</p>