vector-detect-pairwise {ivs} | R Documentation |
Pairwise detect relationships between a vector and an iv
Description
This family of functions detects different types of relationships between a
vector and an iv pairwise. where pairwise means that the i-th value of x
is compared against the i-th value of y
. This is in contrast to
iv_between()
, which works more like base::%in%.
-
iv_pairwise_between()
detects if the i-th value ofx
, a vector, falls between the bounds of the i-th value ofy
, an iv. -
iv_pairwise_includes()
detects if the i-th value ofx
, an iv, includes the i-th value ofy
, a vector.
These functions return a logical vector the same size as the common size of
x
and y
.
Usage
iv_pairwise_between(x, y)
iv_pairwise_includes(x, y)
Arguments
x , y |
For For
|
Value
A logical vector the same size as the common size of x
and y
.
See Also
Locating relationships between a vector and an iv
Detecting relationships between a vector and an iv
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
y
# Does the i-th value of `x` fall between the i-th interval of `y`?
iv_pairwise_between(x, y)
# Does the i-th interval of `y` include the i-th value of `x`?
iv_pairwise_includes(y, x)
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)
iv_pairwise_includes(b, a)