Pete

The original question "I would like to calculate the average of the mean
temperature for the summer months (Juli, August, September) for each of the
20 years"

Your codes gives mean for each of the 3 months, not for the 20 summers.
 
Here is a way to get the summer average for each of the 20 years:

 set.seed = 1
 d=data.frame(year=rep(1980:1999,each=12), month=rep(1:12,20), meanTemp =
rnorm(240,10,5))
 sum_d <- subset(d, d[,2]>=7 & temp_df[,2] <=9)
 aggregate(meanTemp ~ year, data = sum_d, mean)




-- 
View this message in context: 
http://r.789695.n4.nabble.com/Calculate-a-mean-for-several-months-for-several-years-tp3318363p3318567.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.

Reply via email to