Learn R Programming

hydroTSM (version 0.2-0)

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 '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, data.frame or matrix object, with daily/monthly/annual time series. Measurements at several gauging stations can be stored in a data.frame of matrix object, and in that case, each column of x represent the time series measured in each g
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 format for the output time series. See format in format.Date. Possible values are: -) %Y : only the year will be used for the time. Default o
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 format.Date. ONLY required when class(dates)=="factor"<
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

  • an annual zoo object.

See Also

vector2zoo, as.Date, daily2monthly, monthly2annual

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)

Run the code above in your browser using DataLab