View source: R/aanalyse_kinetics_helpers.R
| find_kinetics_idx | R Documentation |
Filters x and t to valid finite values, locates the first valid peak
(maximum) or trough (minimum) where t >= 0, and returns the integer
indices of all finite observations up to end_window past that extreme.
find_kinetics_idx(
x,
t = seq_along(x),
end_window = Inf,
direction = c("auto", "positive", "negative"),
...,
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 |
end_window |
A numeric value in units of |
direction |
A character string specifying the response direction
|
... |
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. |
When direction = "auto", the excursions of x above and below its
initial baseline (the median of the earliest samples) are compared via
detect_direction(). If the upward excursion dominates, the function
searches for a peak (maximum); if the downward excursion dominates, a
trough (minimum). When the excursions tie, the direction is determined
by comparing abs(max(x)) to abs(min(x)), with ties defaulting to
"positive".
Only samples where t >= 0 are used for detecting the extreme, allowing
pre-baseline (negative time) data to be excluded from the search.
However, indices where t < 0 are included in the returned vector
provided they are finite.
A named list with three elements:
directionCharacter; the resolved direction used –
"positive" (peak) or "negative" (trough).
extremeInteger or NULL; the index of the
first qualifying peak or trough in original x
space, or NULL if no qualifying extreme was found
(monotonic, horizontal, or degenerate input).
idxInteger vector of all valid finite indices,
truncated at t[extreme] + end_window.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.