title: Calculating the difference between consecutive rows by group using dplyr?
body: <p>I have a dataframe of ids and timestamps. I'd like to calculate the difference between each sequential timestamp for an individual id.</p>
  
  <p>My dataframe looks like this:</p>
  
  <pre><code>id  time
  Alpha   1
  Alpha   4
  Alpha   7
  Beta    5
  Beta    10
  </code></pre>
  
  <p>I'm trying to add a column like <code>time.difference</code> below:</p>
  
  <pre><code>id  time    time.difference
  Alpha   1   NA
  Alpha   4   3
  Alpha   7   4
  Beta    5   NA
  Beta    10  5
  </code></pre>
  
  <p>Is there a clean way to do this using dplyr? (or tidyr or something else that's easier to read than vanilla R?)</p>