title: R: find row and column where one variable exceeds all others until last row
body: <p>I have data like this (generated by a program rather than by hand, but this is to serve as an example): </p>
  
  <pre><code>a&lt;-c(10,12,18,25,24,26,26,26,22,21)
  b&lt;-c(12,14,14,24,27,26,26,25,20,18)
  x&lt;-c(12,18,20,18,16,14,18,18,20,20)
  d&lt;-as.data.frame(cbind(a,b,x))
  
  
  d
      a  b  x
  1  10 12 12
  2  12 14 18
  3  18 14 20
  4  25 24 18
  5  24 27 16
  6  26 26 14
  7  26 26 18
  8  26 25 18
  9  22 20 20
  10 21 18 20
  </code></pre>
  
  <p>I want to find out which of the 3 variables 'wins', where winning means to have higher value than any other variable from some row until the final row. So in this example, d$a wins, because it has the row-wise maximum value from row 8 onwards -- even though the maximum overall value occurs for d$b at row 6. </p>
  
  <p>So the answer I'd be looking for here would be that d$a wins because it 'dominates' from row 8 onwards. </p>
  
  <p>I can do this with loops, but the reason I'm switching to R is to get away from that approach. Also, the real data has several hundred columns and a few thousand rows, so loops would be quite slow. Any advice would be greatly appreciated! Thanks.</p>