Using the example data set that Ananda dummied up, here's an example using aggregate()
, which is part of core R. aggregate()
just needs something to count as function of the different values of MONTH-YEAR
. In this case, I used VALUE
as the thing to count:
aggregate(cbind(count = VALUE) ~ MONTH.YEAR,
data = mydf,
FUN = function(x){NROW(x)})
which gives you..
MONTH.YEAR count
1 FEB. 2012 2
2 JAN. 2012 2
3 MAR. 2012 1