Skip to content
Prev 165840 / 398502 Next

Odp: the first and last observation for each subject

Hi

r-help-bounces at r-project.org napsal dne 02.01.2009 10:20:23:
time.
sapply(split(test$y, test$ID), function(x) tail(x, 1)-head(x,1))

I am leaving formating to the resulting table to you. Hint: aggregate

Best regards
Petr
http://www.R-project.org/posting-guide.html