vary_threshold {lfstat} | R Documentation |
Create varying thresholds
Description
Helper function to easily create a daily, weekly, monthly or seasonal varying threshold.
Usage
vary_threshold(x, varying = "constant",
fun = function(x) quantile(x, probs = 0.05, na.rm = TRUE), ...)
Arguments
x |
an object which can be coerced to class |
varying |
if |
fun |
a function accepting a single argument and returning either a vector of length one or a vector as long as |
... |
additional arguments, passed on to |
Value
a vector as long as x
.
Examples
data(ngaruroro)
ng <- as.xts(ngaruroro)["1983::1985", ]
r <- find_droughts(ng, varying = "monthly")
plot(r)
thr1 <- vary_threshold(ng, varying = "weekly", fun = mean, na.rm = TRUE)
plot(thr1)
thr2 <- vary_threshold(ng, varying = "monthly", fun = mean, na.rm = TRUE)
lines(thr2, col = 2)
[Package lfstat version 0.9.12 Index]