iv_pairwise_between()
detects when x
, a vector, falls between the
bounds of y
, an iv, pairwise, where pairwise means that the i-th value
of x
is compared against the i-th interval of y
. This is in contrast to
iv_between()
, which works more like base::%in%.
These functions return a logical vector the same size as the common size of
x
and y
.
Arguments
- x, y
[vector, iv]
x
should be a vector andy
should be an iv.x
should have the same type as the start/end components ofy
.These will be recycled against each other.
Examples
x <- as.Date(c("2019-01-01", "2019-01-08", "2019-01-21"))
y <- iv_pairs(
as.Date(c("2019-01-01", "2019-01-03")),
as.Date(c("2019-01-07", "2019-01-09")),
as.Date(c("2019-01-18", "2019-01-21"))
)
x
#> [1] "2019-01-01" "2019-01-08" "2019-01-21"
y
#> <iv<date>[3]>
#> [1] [2019-01-01, 2019-01-03) [2019-01-07, 2019-01-09) [2019-01-18, 2019-01-21)
# Does the i-th value of `x` fall between the i-th interval of `y`?
iv_pairwise_between(x, y)
#> [1] TRUE TRUE FALSE
a <- c(1, NA, NA)
b <- iv_pairs(c(NA, NA), c(3, 4), c(NA, NA))
# Missing intervals always propagate
iv_pairwise_between(a, b)
#> [1] NA NA NA