is_monotonic {mousetRajectory} | R Documentation |
Test if vector is monotonically in-/decreasing
Description
Checks if a numeric_vector
is monotonically in-/decreasing.
In particular, it always a good idea to check the time stamps of trajectory
data and verify that the logging worked properly.
Usage
is_monotonic(numeric_vector, decreasing = FALSE, strict = TRUE, warn = TRUE)
Arguments
numeric_vector |
Number sequence to-be checked. |
decreasing |
Should the |
strict |
Must the values in-/decrease strictly? Defaults to |
warn |
Will a warning be issued if the |
Details
All objects of length 0 or 1 are monotonic. Data with missing values will not pass the check.
Value
A length-one logical, indicating whether the vector is monotonic.
References
Wirth, R., Foerster, A., Kunde, W., & Pfister, R. (2020). Design choices: Empirical recommendations for designing two-dimensional finger tracking experiments. Behavior Research Methods, 52, 2394 - 2416. doi:10.3758/s13428-020-01409-0
Examples
is_monotonic(c(1, 2, 3, 4), warn = FALSE)
is_monotonic(c(1, 2, 2, 3), warn = FALSE)
is_monotonic(c(1, 2, 2, 3), strict = FALSE, warn = FALSE)
is_monotonic(c(4, 0, -1, -1, -5),
decreasing = TRUE,
strict = FALSE, warn = FALSE
)