## Loading daily streamflows (3 years) at the station
## Oca en Ona (Ebro River basin, Spain)
data(OcaEnOnaQts)
x <- OcaEnOnaQts
## Mean monthly streamflows at station 'x'
monthlyfunction(x, FUN=mean, na.rm=TRUE)
############################
## Boxplot of monthly values
## Daily to Monthly
m <- daily2monthly(x, FUN=mean, na.rm=TRUE)
## Median of the monthly values at the station
monthlyfunction(m, FUN=median, na.rm=TRUE)
## Vector with the three-letter abbreviations of the month names
cmonth <- format(time(m), "%b")
## Creating ordered monthly factors
months <- factor(cmonth, levels=unique(cmonth), ordered=TRUE)
## Boxplot of the monthly values
boxplot( coredata(m) ~ months, col="lightblue", main="Monthly streamflows, [m3/s]")
##############################
##############################
## Loading the monthly time series of precipitation within the Ebro River basin.
data(EbroPPtsMonthly)
x <- EbroPPtsMonthly
## Dates of 'x'
dates <- as.Date(x[,1])
# Amount of years in 'x' (needed for computing the average)
nyears <- length( seq(from=dates[1], to=dates[length(dates)], by="years") )
## Monthly precipitation of all the stations in 'x'
## Sum of the monthly values in each station of 'x'
m <- monthlyfunction(x, FUN=sum, dates=1, out.type="db")
## Average monthly precipitation in each station of 'x'
m$Value <- m$Value / nyears
## Creating monthly factors
m$Month <- factor(m$Month, levels=month.abb)
## boxplot of the monthly values in all stations
boxplot(Value ~ Month, m, col="lightyellow", main="Monthly Precipitation, [mm/month]")
Run the code above in your browser using DataLab