Bizarre Dataframe Structure after using dplyr Lead
<p>I simply want to get the lead value for a set of grouped records.  See below</p>

<pre><code>dat &lt;- data.frame(ids = c(1,1,1,1,2,3,4,4))
dat$id &lt;- 1:nrow(dat)
library(dplyr)

y &lt;- tbl_df(dat) %&gt;% 
  group_by(ids) %&gt;% 
  mutate(next_id = lead(id, 1))
</code></pre>

<p>And when you look at the structure of <code>y</code></p>

<pre><code>&gt; str(y)
Classes ‘grouped_df’, ‘tbl_df’, ‘tbl’ and 'data.frame': 8 obs. of  3 variables:
 $ ids    : num  1 1 1 1 2 3 4 4
 $ id     : int  1 2 3 4 5 6 7 8
 $ next_id: int  2 3 4 NA NA NA 8 NA
 - attr(*, "vars")=List of 1
  ..$ : symbol ids
 - attr(*, "labels")='data.frame':  4 obs. of  1 variable:
  ..$ ids: num  1 2 3 4
  ..- attr(*, "vars")=List of 1
  .. ..$ : symbol ids
  ..- attr(*, "drop")= logi TRUE
 - attr(*, "indices")=List of 4
  ..$ : int  0 1 2 3
  ..$ : int 4
  ..$ : int 5
  ..$ : int  6 7
</code></pre>

<p>What I was expecting was just a simple <code>int</code> column, not a nested data structure.</p>

<p>I am sure that I am missing something obvious, but any help will be greatly appreciated.</p>