Hello everybody,

Data is
myd <- data.frame(id1=rep(c("a","b","c"),each=3),id2=rep(1:3,3),val=rnorm(9))

I want to get a cumulative sum over each of id1. trying aggregate does not work

myd$pcum <- aggregate(myd[,c("val")],list(orig=myd$id1),cumsum)

Please suggest a solution. In real the dataframe is huge so looping with for and subsetting is not a great idea (still doable, though).
Thank you


Stephen B


	[[alternative HTML version deleted]]

