Re: [R] function by: order within subsets

2010-01-08 Thread Gabor Grothendieck
Try ave: transform(df, v = ave(v, f, FUN = cumsum)) On Fri, Jan 8, 2010 at 1:10 PM, Daniel Murphy wrote: > When the 'by' function forms subsets, are the rows in the same order as they > are in the original data frame? > > For example, I want to use 'by' to calculate cumulative sums of a value '

Re: [R] function by: order within subsets

2010-01-08 Thread Henrique Dallazuanna
Try this: transform(df, v = unlist(with(df, tapply(v, f, cumsum On Fri, Jan 8, 2010 at 4:10 PM, Daniel Murphy wrote: > When the 'by' function forms subsets, are the rows in the same order as they > are in the original data frame? > > For example, I want to use 'by' to calculate cumulative su