[R] the first and last observation for each subject

hadley wickham h.wickham at gmail.com
Mon Jan 5 05:56:09 CET 2009


>> 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/




More information about the R-help mailing list