relation-detect-pairwise | R Documentation |
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 specific type
of overlap
between the i-th interval of x
and the i-th interval of y
.
iv_pairwise_precedes()
detects if the i-th interval of x
precedes (i.e. comes before) the i-th interval of y
.
iv_pairwise_follows()
detects if the i-th interval of x
follows (i.e. comes after) the i-th interval of y
.
These functions return a logical vector the same size as the common size of
x
and y
.
iv_pairwise_overlaps(x, y, ..., type = "any") iv_pairwise_precedes(x, y) iv_pairwise_follows(x, y)
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:
|
A logical vector the same size as the common size of x
and y
.
Locating relationships
Detecting relationships
Locating relations from Allen's Interval Algebra
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.