title: R: finding column with minimum value in each row when there is a tied
body: <p>Here is my data example: </p>
  
  <pre><code>&gt;dat &lt;- matrix(c(59,50,48,44,44,NA,78,59,42,67,51,NA,72,64,64),byrow=TRUE,ncol=3) 
  &gt;k &lt;- apply(dat, 1, function(x) which(x == min(x, na.rm = TRUE)))
  &gt;k
  [[1]]
  [1] 3
  
  [[2]]
  [1] 1 2
  
  [[3]]
  [1] 3
  
  [[4]]
  [1] 2
  
  [[5]]
  [1] 2 3
  </code></pre>
  
  <p>But, I want the output like this:  </p>
  
  <blockquote>
    <p>k<br>
         3 2 3 2 3  </p>
  </blockquote>
  
  <p>Many thanks in advance.</p>