My data frame looks somewhat like this
1976 January 250
1976 February 350
1976 March 230
1976 April 255
This goes up to 2007
I want to aggregate and find the mean of the data per year. I want to create a variable that would contain a table of data mean by each year. So that it looks like
1976 mean of all 1976 months
1977 mean of all 1976 months
1978 mean of all 1976 months
1979 mean of all 1976 months
and so on
How can I do it?
The data frame is "data" and the first column is "year"
variable_name <- aggregate(x=data$secondcolumn_name, by=list(data$Year), FUN="mean")
But it is not getting aggregated. I think since the column "year" has characters is the problem.