ThresholdFunctions {gcplyr} | R Documentation |
Find point(s) when a numeric vector crosses some threshold
Description
These functions take a vector of y
values and identify points where
the y
values cross some threshold
y value.
Usage
find_threshold_crosses(
y,
x = NULL,
threshold,
return = "index",
return_rising = TRUE,
return_falling = TRUE,
return_endpoints = TRUE,
subset = NULL,
na.rm = TRUE
)
first_below(
y,
x = NULL,
threshold,
return = "index",
return_endpoints = TRUE,
...
)
first_above(
y,
x = NULL,
threshold,
return = "index",
return_endpoints = TRUE,
...
)
Arguments
y |
Numeric vector of y values in which to identify threshold crossing event(s) |
x |
Optional numeric vector of corresponding x values |
threshold |
Threshold y value of interest |
return |
One of If If |
return_rising |
logical for whether crossing events where |
return_falling |
logical for whether crossing events where |
return_endpoints |
logical for whether startpoint should be returned
when the startpoint is above |
subset |
A vector of logical values indicating which x and y values should be included (TRUE) or excluded (FALSE). If |
na.rm |
logical whether NA's should be removed before analyzing.
If |
... |
(for |
Value
find_threshold_crosses
returns a vector corresponding to all the
threshold crossings.
first_above
returns only the first time the y
values
rise above the threshold, so is a shortcut for
find_threshold_crosses(return_rising = TRUE, return_falling = FALSE)[1]
first_below
returns only the first time the y
values
fall below the threshold, so is a shortcut for
find_threshold_crosses(return_rising = FALSE, return_falling = TRUE)[1]
If return = "index"
, the returned value(s) are the indices
immediately following threshold crossing(s)
If return = "x"
, the returned value(s) are the x value(s)
corresponding to threshold crossing(s)
If no threshold-crossings are detected that meet the criteria, will
return NA