View source: R/analyse_peak_slope.R
| rolling_slope | R Documentation |
rolling_slope(): Compute rolling linear regression slopes within a local
window along a numeric vector.
slope(): Calculate the linear regression slope of a numeric vector via
the least-squares formula.
rolling_slope(
x,
t = seq_along(x),
width = NULL,
span = NULL,
align = c("centre", "left", "right"),
partial = FALSE,
na.rm = FALSE,
verbose = TRUE,
...,
env = rlang::caller_env()
)
slope(x, t = seq_along(x), na.rm = FALSE, ..., env = rlang::caller_env())
x |
A numeric vector of the response variable. |
t |
An optional numeric vector of the predictor variable (e.g. time).
Default is |
width |
An integer defining the local window in number of samples
around |
span |
A numeric value defining the local window time span around |
align |
Window alignment as "centre"/"center" (the default), "left", or "right". Where "left" is forward looking, and "right" is backward looking from the current sample. |
partial |
Logical; default is |
na.rm |
Logical; default is |
verbose |
Logical. |
... |
Additional arguments. |
env |
The calling environment or a defused call, used to report errors and warnings as coming from the user-facing function rather than the validator. |
See peak_slope() for details on window specification (width, span,
align), partial windows, and direction detection.
Additional arguments (...) accepted:
bypass_checksLogical; if TRUE, skips input validation.
Intended for internal use when checks have already been performed
upstream.
min_obsInteger; minimum number of valid observations required
per window to return a slope. Derived from width or span, or 2L
when partial = TRUE.
interceptLogical; if TRUE, slope() also attaches the
y-intercept as attr(slope_val, "intercept").
window_idxLogical; if TRUE, the window bounds from
compute_window_bounds() are attached as attr(slopes, "bounds").
rolling_slope() returns a numeric vector of rolling local slopes
in units of x / t, the same length as x.
slope() returns a numeric slope value in units of x / t, or
NA_real_ when insufficient valid observations are present.
peak_slope()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.