Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

subdaily2daily

Sub-daily -> Daily


Description

Generic function for transforming a Sub-DAILY time series into a DAILY one

Usage

subdaily2daily(x, ...)

## Default S3 method:
subdaily2daily(x, FUN, na.rm = TRUE, start="00:00:00", ...)

## S3 method for class 'zoo'
subdaily2daily(x, FUN, na.rm = TRUE, start="00:00:00", ...)

## S3 method for class 'data.frame'
subdaily2daily(x, FUN, na.rm = TRUE, start="00:00:00",
           dates=1, date.fmt="%Y-%m-%d %H:%M:%S", out.fmt="zoo", 
           verbose= TRUE, ...)

## S3 method for class 'matrix'
subdaily2daily(x, FUN, na.rm = TRUE, start="00:00:00",
           dates=1, date.fmt="%Y-%m-%d %H:%M:%S", out.fmt="zoo", 
           verbose= TRUE, ...)

Arguments

x

xts, data.frame or matrix object, with sub-daily 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 gauging station, and the column names of x should correspond to the ID of each station (starting by a letter).

FUN

Function that have to be applied for transforming from sub-daily to daily 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 daily values are computed considering only those values different from NA
-) FALSE: if there is AT LEAST one NA sub-daily value within a day, the corresponing daily value(s) will be NA as well

start

character, indicating the starting time used for aggregating subdaily time series into daily ones. It MUST be provided in the "%H:%M:%S" format.

dates

numeric, factor, POSIXct or POSIXt object indicating how to obtain the dates and times for each gauging station
If dates is a number, it indicates the index of the column in x that stores the date and times
If dates is a factor, it is converted into POSIXct class, using the date format specified by date.fmt
If dates is already of POSIXct or POSIXt class, the code verifies that the number of elements on it be equal to the number of elements in x

date.fmt

character indicating the format in which the dates are stored in dates, By default date.fmt=%Y-%m-%d %H:%M:%S. See format in as.Date.
ONLY required when class(dates)=="factor" or class(dates)=="numeric".

out.fmt

OPTIONAL. Only used when x is a matrix or data.frame object /cr character, for selecting if the result will be a matrix/data.frame or a zoo object. Valid values are: numeric, zoo (default)

verbose

logical; if TRUE, progress messages are printed

...

further arguments passed to or from other methods.

Author(s)

Mauricio Zambrano-Bigiarini, mzb.devel@gmail

See Also

Examples

## Loading the time series of hourly streamflows for the station Karamea at Gorge
data(KarameaAtGorgeQts)
x <- KarameaAtGorgeQts

# Plotting the hourly streamflow values
plot(x)

## sub-daily to Daily
d <- subdaily2daily(x, FUN=sum, na.rm=TRUE)

# Plotting the daily streamflow values
plot(d)

hydroTSM

Time Series Management, Analysis and Interpolation for Hydrological Modelling

v0.6-0
GPL (>= 2)
Authors
Mauricio Zambrano-Bigiarini [aut, cre, cph] (<https://orcid.org/0000-0002-9536-643X>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.