I have dataframe df with x,y,and monthly.year data for each x,y point.
I am trying to get the seasonal aggregate.
I need to calculate seasonal means i.e.
For winter mean of (December,January,February); for Spring mean of (March,April,May), for Summer mean of (June,July,August) and for autumn mean of (September,October,November).
The data looks similar to:
set.seed(1)
df <- data.frame(x=1:3,y=1:3, matrix(rnorm(72),nrow=3) )
names(df)[3:26] <- paste(month.abb,rep(2009:2010,each=12),sep=".")
x y Jan.2009 Feb.2009 ... Dec.2010
1 1 1 -0.6264538 1.5952808 ... 2.1726117
2 2 2 0.1836433 0.3295078 ... 0.4755095
3 3 3 -0.8356286 -0.8204684 ... -0.7099464
I could not think of going any further except melting the data and making new data frame as
ddt.m<-melt(df,id=c("x","y"))
I want result like x,y,mean of season of each year. Please suggest me how I may be able to do that.