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%.

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

⁠[vector, iv]⁠

For iv_pairwise_between(), x must be a vector and y must be an iv.

For iv_pairwise_includes(), x must be an iv and y must be a vector.

x and y will be recycled against each other.

Value

A logical vector the same size as the common size of x and y.

See Also

Locating relationships

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)

[Package ivs version 0.2.0 Index]