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 '
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
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 'v'
by date 'd' for different levels of a factor 'f':
>
df<-data.frame(f=c("A","A","B"),d=as.Date(c("2010-1-1","2010
3 matches
Mail list logo