Learn R Programming

hydroTSM (version 0.3-5)

daily2annual: Daily -> Annual

Description

Generic function for transforming a DAILY/MONTHLY regular time series into an ANNUAL one.

Usage

daily2annual(x, ...)

## S3 method for class 'default': daily2annual(x, FUN, na.rm = TRUE, out.fmt = "\%Y", ...)

## S3 method for class 'zoo': daily2annual(x, FUN, na.rm = TRUE, out.fmt = "\%Y-\%m-\%d", ...)

## S3 method for class 'data.frame': daily2annual(x, FUN, na.rm = TRUE, out.fmt = "\%Y", dates, date.fmt = "\%Y-\%m-\%d", out.type = "data.frame", verbose = TRUE, ...)

## S3 method for class 'matrix': daily2annual(x, FUN, na.rm = TRUE, out.fmt = "\%Y", dates, date.fmt = "\%Y-\%m-\%d", out.type = "data.frame", verbose = TRUE, ...)

Arguments

x
zoo, xts, data.frame or matrix object, with daily/monthly time series. Measurements at several gauging stations can be stored in a data.frame or matrix object, and in that case, each column of x represent the time series measured in each gau
FUN
Function that have to be applied for transforming from daily/monthly to annual time step (e.g., for precipitation FUN=sum and for temperature and streamflows ts, FUN=mean).
na.rm
Logical. Should missing values be removed? -) TRUE : the monthly and annual values are computed considering only those values different from NA -) FALSE: if there is AT LEAST one NA within a year, the corresponding annual value is
out.fmt
Character indicating the date format for the output time series. See format in as.Date. Possible values are: -) %Y : only the year will be used for the time. Default opti
dates
numeric, factor or Date object indicating how to obtain the dates for corresponding to each gauging station If dates is a number, it indicates the index of the column in x that stores the dates If dates is a factor
date.fmt
character indicating the format in which the dates are stored in dates, e.g. %Y-%m-%d. See format in as.Date. ONLY required when class(dates)=="factor" o
out.type
Character that defines the desired type of output. Valid values are: -) data.frame: a data.frame, with as many columns as stations are included in x, and row names indicating the Year -) db : a data.frame, with
verbose
logical; if TRUE, progress messages are printed
...
further arguments passed to or from other methods.

Value

  • a zoo object with annual frequency

See Also

daily2monthly, monthly2annual, hydroplot, annualfunction, vector2zoo, as.Date

Examples

Run this code
## Loading the SanMartino precipitation data
data(SanMartinoPPts)
x <- SanMartinoPPts

## Daily to Monthly
m <- daily2monthly(x, FUN=sum, na.rm=TRUE)

## Daily to Annual
daily2annual(x, FUN=sum, na.rm=TRUE)

## Monthly to Annual
monthly2annual(m, FUN=sum, na.rm=TRUE)

############
## Loading the monthly time series of precipitation within the Ebro River basin.
data(EbroPPtsMonthly)

# computing the annual values for the first 10 gauging station in 'EbroPPtsMonthly'
a <- monthly2annual(EbroPPtsMonthly[,1:11], FUN=sum, dates=1)

# same as before, but with a nicer format of years
a <- monthly2annual(EbroPPtsMonthly[,1:11], FUN=sum, dates=1, out.fmt="%Y")

Run the code above in your browser using DataLab