Thank you both for your answers. I found a best way to delete the first 2 months (Jan + Feb) and the last month (Dec), which should work everytime:
DF$year <- as.numeric(format(DF$Day, format = "%Y")) DF$month <- as.numeric(format(DF$Day, format = "%m")) # delete first 2 months for(i in DF[1,3]) # column year ifelse(i==2008,(DF= DF[c(-(1:60)),]),(DF=DF[c(-(1:59)),])) I delete the first 60 days if the first year if my file starts with a leap year (I'll need just to add the new leap years afterwords), and the 59 first days if it's not. # delete last month DF= DF[c(-((nrowDF)-30):nrow(DF))),] I did a mistake next for the seasons: - winter should be month 12,1,2 (so month 12 of the previous year, that's why I deleted the first 2 months) - spring: month 3,4,5 - summer: month 6,7,8 - autumn: month 9,10,11 Now my file starts month 3 of the first year (as I deleted the first 2 months). My first year has so: month 3,4,5,6,7,8,9,10,11,12 and the nest year: month 1,2,3,4,5,6,7,8,9,10,11 (we imagine a file with just 2 years). I tried to modify your proposition but it doesn't work yet. Could you help me again with this new version of season? Thank you very much Ricardogg -- View this message in context: http://r.789695.n4.nabble.com/how-to-calculate-seasonal-mean-for-temperatures-tp4638639p4638651.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.