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
A sql solution using sqldf package:
sqldf
library(sqldf) sqldf("SELECT Year, Month, COUNT(*) as Freq FROM df1 GROUP BY Year, Month")