View source: R/Functions_AcrossYears.R
calc_climatology | R Documentation |
Calculate across-year summaries
calc_climatology(X, INDEX, FUN, ...)
X |
A numeric vector, matrix or data.frame. Rows represent time steps. |
INDEX |
A numeric vector. Time steps of |
FUN |
A function or a name of a function.
The function must accept |
... |
Additional parameters passed to |
A numeric data.frame where
rows represent unique values of INDEX
and
columns represent combinations of columns of x
and FUN
output.
Columns names contain combinations of names of x
and FUN
if
available.
The package rSW2metrics offers two pathways to across-year summaries:
aggs_across_years()
calculates across-year summaries
from output of a time-series metric; this can be calculated after
extractions or requested with
command-line options -add_aggs_across_yrs
and -ts
.
Metrics that directly return across-year summaries,
i.e., climatologies;
those are internally calculated by calc_climatology()
.
Both pathways utilize the user-defined function fun_aggs_across_yrs()
from "Project_Parameters.R.
calc_climatology(
1:100,
INDEX = rep(1:10, each = 10),
FUN = function(x, ...) {
tmp <- unname(quantile(x, probs = c(0.05, 0.5, 0.95), ...))
c(low = tmp[[1]], med = tmp[[2]], high = tmp[[3]])
},
type = 1
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.