I have data in two columns: its date, and a factor variable. A fragment of my data:
Date Category
1 2009-06-22 BREAD
2 2009-06-23 BREAD
3 2009-06-23 BREAD
4 2009-06-23 JAM
5 2009-06-23 MILK
6 2009-06-24 BREAD
9 2009-06-24 MILK
10 2009-06-25 JAM
Problem: I need to count how many of each Category
type appeared on each month of each year.
I tried approaches like this, using aggregate
, but I don't know how to fit the factor variable there.
Data Sample: Here is a workable data sample (with more months and years): http://rextester.com/DYMXN47464 Of course, my final (real) data goes from 2009 to 2018, with each month of each year, but those are too many observations, and I cannot share the whole data.