Skip to content
Prev 200468 / 398503 Next

extracting the last row of each group in a data frame

I would use pkg:plyr, but just to show how
versatile R is:

ind <- cumsum(rle(as.numeric(dat$Name))$lengths)
dat[ind, ]

where I'm assuming that your data frame is
called 'dat'.

  -Peter Ehlers
Hao Cen wrote: