I have a data frame with about 200 columns, out of them I want to group the table by first 10 or so which are factors and sum the rest of the columns.
I have list of
The dplyr way would be:
dplyr
library(dplyr) df %>% group_by(col1, col2, col3) %>% summarise_each(funs(sum))
You can further specify the columns to be summarised or excluded from the summarise_each by using the special functions mentioned in the help file of ?dplyr::select.
summarise_each
?dplyr::select