Skip to content
Prev 179041 / 398506 Next

sequence number for 'long format'

If your data is sorted so that identical id values are always contiguous
you can replace the by() with
     sequence(rle(ds$id)$lengths)
23338043p23338043.html