apply.seasonal | R Documentation |
Similar to the functions apply.daily
, apply.monthly
, apply.yearly
etc. from the xts package.
apply.seasonal(x, varying, fun = function(x) min(x, na.rm = TRUE), aggregate = NULL, replace.inf = TRUE, origin = 1)
x |
an object of class |
varying |
a character vector of length one of a possibly named vector of class |
fun |
the function used for aggregating all elements of a season. |
aggregate |
possibly a function used for aggregating per season. |
replace.inf |
should non-finite values introduced by |
origin |
The start of the hydrological year. If set to 1 (the default) aggregation is carried out using the calendar year. |
a matrix with every (hydrological) year being a row and every column being a season.
data(ngaruroro) ng <- as.xts(ngaruroro) year <- water_year(time(ng), origin = "Sept") ng10 <- ng[year %in% 1991:2000, ] # computes the annual minima (AM) apply.seasonal(ng10, varying = "yearly", origin = 9) # computes the mean annual minima (MAM) apply.seasonal(ng10, varying = "yearly", aggregate = mean, origin = 9) # computes monthly minima (AM) apply.seasonal(ng10, varying = "monthly", origin = 9) # computes minima for summer and winter separately # winter starts in September seasons <- as.Date(c("1999-09-01", "1999-11-04")) names(seasons) <- c("winter", "summer") apply.seasonal(ng10$discharge, varying = seasons, origin = 9)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.