title: subtract first value from each subset of dataframe
body: <p>I want to subtract the smallest value in each subset of a data frame from each value in that subset i.e.</p>
  
  <pre><code>A &lt;- c(1,3,5,6,4,5,6,7,10)
  B &lt;- rep(1:4, length.out=length(A))
  df &lt;- data.frame(A, B)
  df &lt;- df[order(B),]
  </code></pre>
  
  <p>Subtracting would give me:</p>
  
  <pre><code>  A B
  1 0 1
  2 3 1
  3 9 1
  4 0 2
  5 2 2
  6 0 3
  7 1 3
  8 0 4
  9 1 4
  </code></pre>