[R] how to calculate seasonal mean for temperatures

jeff6868 geoffrey_klein at etu.u-bourgogne.fr
Wed Aug 1 13:30:50 CEST 2012


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.



More information about the R-help mailing list