title: Calculate difference between values in consecutive rows by group
body: <p>This is a my <code>df</code> (data.frame):</p>
  
  <pre><code>group value
  1     10
  1     20
  1     25
  2     5
  2     10
  2     15 
  </code></pre>
  
  <p>I need to calculate difference between values in consecutive rows by group.</p>
  
  <p>So, I need a that result.</p>
  
  <pre><code>group value diff
  1     10    NA # because there is a no previous value
  1     20    10 # value[2] - value[1]
  1     25    5  # value[3] value[2]
  2     5     NA # because group is changed
  2     10    5  # value[5] - value[4]
  2     15    5  # value[6] - value[5]
  </code></pre>
  
  <p>Although, I can handle this problem by using <code>ddply</code>, but it takes too much time. This is because I have a lot of groups in my <code>df</code>. (over 1,000,000 groups in my <code>df</code>)</p>
  
  <p>Are there any other effective approaches to handle this problem?</p>