library(data.table)
data <- data.table(group1=c('A','A','A','B','B'),sum=c(1,2,4,3,7))
data[,list(cumsum = cumsum(sum)),by=list(group1)]
More Related Contents:
- Calculate cumulative sum (cumsum) by group
- Cumulative sum until maximum reached, then repeat from zero in the next row
- Conditional cumsum with reset
- Rowwise cumulative sum
- resetting cumsum if value goes to negative in r
- How to convert string rule to an expression which has a range in R [closed]
- How does one access the piped data.frame in dplyr::funs?
- Using ggplot2, can I insert a break in the axis?
- Installing older version of R package
- How to subset matrix to one column, maintain matrix data type, maintain row/column names?
- Filter multiple values on a string column in dplyr
- Fixing the order of facets in ggplot
- Loop in R to read many files
- Read all files in a folder and apply a function to each data frame
- Change the class from factor to numeric of many columns in a data frame
- Forcing garbage collection to run in R with the gc() command
- R: How to handle times without dates?
- Converting nested list to dataframe
- Align ggplot2 plots vertically
- Calculate row-wise maximum
- How to delete rows where all the columns are zero
- using parallel’s parLapply: unable to access variables within parallel code
- How to move or position a legend in ggplot2
- Transposing a dataframe maintaining the first column as heading
- Using get() with replacement functions
- Replace a value NA with the value from another column in R
- Insert a row in a data.table
- Clarification of L in R
- Convert integer as “20160119” to different columns of “day” “year” “month”
- Convert two-digit years to four-digit years with correct century