betwixt | R Documentation |
This is utility function to find values of a vector tha fall between lower and upper bounds specified. The implementation includes a method to optionally ignore certain values and return either a vector of logical indices or a vector of matching values. Inspired by between.
betwixt(x, lower, upper, ignore = NULL, by = 1, value = FALSE)
x |
Vector of numeric or date values |
lower |
The lower bound (inclusive) for the range of values |
upper |
The upper bound (inclusive) for the range of values |
ignore |
Vector containing value(s) to exclude; default is |
by |
Value for increment between lower and upper bounds of the range; default is |
value |
Boolean as to whether the function should return values of |
Depending on the "value" argument, this will either return a vector of values that fall between the lower and upper bounds or a vector of logical vector with TRUE
for each index corresponding to a value that falls in the range.
betwixt(1:12, 7, 9) betwixt(1:12, 7, 9, value = TRUE) dates <- seq(as.Date("2000/1/1"), by = "day", length.out = 365) betwixt(dates, lower = as.Date("2000/1/10"), upper = as.Date("2000/3/10"), by = "day", ignore = as.Date("2000/1/25"), value = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.