## Loading the SanMartino precipitation data
data(SanMartinoPPts)
x <- SanMartinoPPts
## Daily to Annual
a <- daily2annual(x, FUN=sum, na.rm=TRUE)
# Amount of years
nyears <- length(seq(from=as.Date("1921-01-01"), to=as.Date("1990-12-31"), by="years"))
## Mean annual precipitation.
# It is necessary to divide by the amount of years to obtain the mean annual value,
# otherwise it will give the total precipitation for all the 70 years
seasonalfunction(x, FUN=sum, na.rm=TRUE) / nyears
#####################
### verification ####
# Mean winter (DJF) value
sum( extractzoo(x, trgt="DJF") ) / nyears
# Mean spring (MAM) value
sum( extractzoo(x, trgt="MAM") ) / nyears
# Mean summer (JJA) value
sum( extractzoo(x, trgt="JJA") ) / nyears
# Mean autumn (SON) value
sum( extractzoo(x, trgt="SON") ) / nyears
Run the code above in your browser using DataLab