For 5 years .... set.seed = 1 d=data.frame(year=rep(2007:2011,each=12), month=rep(1:12,5), meanTemp = rnorm(60,10,5)) meanByMonth = ave(d$meanTemp, d$month, FUN = mean)[7:9]
HTH Pete -- View this message in context: http://r.789695.n4.nabble.com/Calculate-a-mean-for-several-months-for-several-years-tp3318363p3318501.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.