relation-detect-pairwise {ivs} | R Documentation |
Pairwise detect a relationship between two ivs
Description
This family of functions detects different types of relationships between
two ivs pairwise, where pairwise means that the i-th interval of
x
is compared against the i-th interval of y
. This is in contrast to
iv_overlaps()
, which works more like base::%in%.
-
iv_pairwise_overlaps()
detects a specifictype
of overlap between the i-th interval ofx
and the i-th interval ofy
. -
iv_pairwise_precedes()
detects if the i-th interval ofx
precedes (i.e. comes before) the i-th interval ofy
. -
iv_pairwise_follows()
detects if the i-th interval ofx
follows (i.e. comes after) the i-th interval ofy
.
These functions return a logical vector the same size as the common size of
x
and y
.
Usage
iv_pairwise_overlaps(x, y, ..., type = "any")
iv_pairwise_precedes(x, y)
iv_pairwise_follows(x, y)
Arguments
x , y |
A pair of interval vectors. These will be recycled against each other and cast to the same type. |
... |
These dots are for future extensions and must be empty. |
type |
The type of relationship to find. One of:
|
Value
A logical vector the same size as the common size of x
and y
.
See Also
Locating relations from Allen's Interval Algebra
Examples
library(vctrs)
x <- iv_pairs(
as.Date(c("2019-01-05", "2019-01-10")),
as.Date(c("2019-01-07", "2019-01-15")),
as.Date(c("2019-01-20", "2019-01-31"))
)
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 interval of `x` overlap the i-th interval of `y`?
iv_pairwise_overlaps(x, y)
# Does the i-th interval of `x` contain the i-th interval of `y`?
iv_pairwise_overlaps(x, y, type = "contains")
# Does the i-th interval of `x` follow the i-th interval of `y`?
iv_pairwise_follows(x, y)
a <- iv_pairs(c(1, 2), c(NA, NA), c(NA, NA))
b <- iv_pairs(c(NA, NA), c(3, 4), c(NA, NA))
# Missing intervals always propagate
iv_pairwise_overlaps(a, b)