Learn R Programming

hydroTSM (version 0.3-4)

daily2monthly: Daily -> Monthly

Description

Generic function for transforming a DAILY regular time series into a MONTHLY one

Usage

daily2monthly(x, ...)

## S3 method for class 'default': daily2monthly(x, FUN, na.rm = TRUE, ...)

## S3 method for class 'zoo': daily2monthly(x, FUN, na.rm = TRUE, ...)

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

## S3 method for class 'matrix': daily2monthly(x, FUN, na.rm = TRUE, dates, date.fmt = "\%Y-\%m-\%d", out.type = "data.frame", out.fmt="numeric", 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 to annual time step. (e.g., for precipitation FUN=sum and for temperature and streamflow 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 monthly values are NA
dates
numeric, factor or Date object indicating how to obtain the dates for 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, it is converted i
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 month and year for each value. -) db
out.fmt
character, for selecting if the result will be a numeric or zoo object. Valid values are: numeric, zoo.
verbose
logical; if TRUE, progress messages are printed
...
further arguments passed to or from other methods.

See Also

daily2annual, monthlyfunction, hydroplot, vector2zoo, izoo2rzoo, 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)

Run the code above in your browser using DataLab