>> easy to understand. Another approach is more specialized but useful >> when you have lots of ID's (e.g., millions) and speed is very important. >> It computes where the first and last entry for each ID in a vectorized >> computation, akin to the computation that rle() uses: > > I particularly this solution to the problem - it's a very handy
Oops, that should be particularly like, of course! > technique, and while it takes a while to get your head around how it > works, it's worthwhile spending the time to do so because it crops up > as a useful solution to many similar types of problems. (It can be > particularly useful in excel too, as a quick way of locating > boundaries between groups) Hadley -- http://had.co.nz/ ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.