# NOT RUN {
## Loading the SanMartino precipitation data
data(SanMartinoPPts)
x <- SanMartinoPPts
# Amount of years
nyears <- yip(from=start(x), to=end(x), out.type="nmbr")
## 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
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab