How to keep a subsetted value for calculating mean
You can answer this using tapply, which will give you the mean for all your subsets, e.g.

dummy data

df = data.frame(mon=rep(month.abb, times=10)


calculate mean for all months

tapply(df$temp, df$mon, mean, na.rm=T)