Thanks to the ones who provided me with answers.
When everything is put together, it appears that everyone came up with
roughly the same answer:
using sapply and unlist functions.
The clearest option to me was the one provided by Bert Gunter which does
exaxctly what I want, i.e getting a dataframe with the cumulative sum at
each observation for each patients.
out<-tapply(temp$tex,list(temp$id),cumsum)
l.out<-sapply(out,length)
out.df<-data.frame(id=rep(names(out),l.out),csum=unlist(out))
I tried the function aggegate suggested by Adrienne but I could not sorted
out what was going wrong but it doesn't work yet.
Thanks to everyone and have a nice day,
Vincent
|