I have some data in the following format:
date x
2001/06 9949
2001/07 8554
2001/08 6954
2001/09 7568
2001/10 11238
2001/11 11969
... more rows
I want to extract the x mean for each month. I tried some code with aggregate, but
failed. Thanks for any help on doing this.
Here I simulate a data frame called
dfwith more data:Using the way your
datevector is constructed you can obtain months by removing the firs four digits followed by a forward slash. Here I use this as indexing variable intapplyto compute the means: