Here is my approximation:
# Creation of the temporal variables DF$year <- as.numeric(format(DF$date, format = "%Y")) DF$month <- as.numeric(format(DF$date, format = "%m")) # For years with data from 2006 to 2008 DF_type1 <- DF [ - which (year == 2006 & month ==1 | year == 2006 & month == 2 | year == 2008 & month == 12), ] # For years with data from 2007 to 2011 DF_type2 <- DF [ - which (year == 2007 & month ==1 | year == 2007 & month == 2 | year == 2011 & month == 12), ] # Including the Season as a factor DF$season <- factor ( with ( ifelse (( month == 1 | nonth == 2 | month == 3 ), "Win", ifelse ((month == 4 | nonth == 5 | month == 6 ) , "Spr", ifelse ((month == 6 | nonth == 7 | month == 8 ) , "Sum", "Aut"))))) # To get the mean per year and season library (plyr) ddply ( DF, . (year, season), summarize, mean_season = mean (data)) -- View this message in context: http://r.789695.n4.nabble.com/how-to-calculate-seasonal-mean-for-temperatures-tp4638639p4638649.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.