title: R data table: use function on group except current row
body: <p>Suppose I have:</p>
  
  <pre><code>x = data.table( id=c(1,1,1,2,2,2), price=c(100,110,120,200,200,220) )
  &gt; x
     id price
  1:  1   100
  2:  1   110
  3:  1   120
  4:  2   200
  5:  2   200
  6:  2   220
  </code></pre>
  
  <p>and want to find for each row the cheapest price in the group (by=id) once the current row is omitted.
  so the results should look like:</p>
  
  <pre><code>&gt; x
     id price   cheapest_in_this_id_omitting_current_row
  1:  1   100   110       # if I take this row out the cheapest is the next row
  2:  1   110   100       # row 1
  3:  1   120   100       # row 1
  4:  2   200   200       # row 5
  5:  2   200   200       # row 4 (or 5)
  6:  2   220   200       # row 4 (or 5)
  </code></pre>
  
  <p>So it is like using:</p>
  
  <pre><code>x[, cheapest_by_id := min(price), id]
  </code></pre>
  
  <p>but <em>removing the current row for each calculation</em>.</p>
  
  <p>If I could have a variable that refers to the current row inside the group like a .row_nb, I would use:</p>
  
  <pre><code>x[, min(price[-.row_nb]), id]
  </code></pre>
  
  <p>but this .row_nb does not seem to exist...?</p>