The data.table way is :
DT[, lapply(.SD,sum), by=list(col1,col2,col3,...)]
or
DT[, lapply(.SD,sum), by=colnames(DT)[1:10]]
where .SD
is the (S)ubset of (D)ata excluding group columns. (Aside: If you need to refer to group columns generically, they are in .BY
.)
More Related Contents:
- Aggregate / summarize multiple variables per group (e.g. sum, mean)
- Faster ways to calculate frequencies and cast from long to wide
- Extract row corresponding to minimum value of a variable by group
- How to create a lag variable within each group?
- Fastest way to add rows for missing time steps?
- Aggregate a dataframe on a given column and display another column
- Aggregate a data frame based on unordered pairs of columns
- Why is plyr so slow?
- Returning first row of group
- Get the means of sub groups of means in R
- R use ddply or aggregate
- Why does data.table update names(DT) by reference, even if I assign to another variable?
- How to get week numbers from dates?
- Which data.table syntax for left join (one column) to prefer
- Evaluating both column name and the target value within `j` expression within `data.table`
- Fill in missing values by group in data.table
- dplyr on data.table, am I really using data.table?
- data.table and parallel computing
- how to show a legend on dual y-axis ggplot
- Why is as.Date slow on a character vector?
- aggregate() puts multiple output columns in a matrix instead
- data.frame Group By column [duplicate]
- How to group data.table by multiple columns?
- Apply a function to a subset of data.table columns, by column-indices instead of name
- Selecting a subset of columns in a data.table
- Merge overlapping ranges into unique groups, in dataframe
- add missing rows to a data table
- Trouble converting long list of data.frames (~1 million) to single data.frame using do.call and ldply
- assigning by reference into loaded package datasets
- calculating sum of previous 3 rows in R data.table (by grid-square)