I have a dataframe and I would like to count the number of rows within each group. I reguarly use the aggregate function to sum data as follows:
aggregate
An old question without a data.table solution. So here goes...
data.table
Using .N
.N
library(data.table) DT <- data.table(df) DT[, .N, by = list(year, month)]