iv-set-pairwise {ivs}R Documentation

Pairwise set operations

Description

This family of functions performs pairwise set operations on two ivs. Pairwise refers to the fact that the i-th interval of x is going to be compared against the i-th interval of y. This is in contrast to their counterparts, like iv_set_union(), which treat the entire vector of x as a single set to be compared against all of y.

The descriptions of these operations are the same as their non-pairwise counterparts, but the ones here also have a number of restrictions due to the fact that each must return an output that is the same size as its inputs:

Usage

iv_pairwise_set_complement(x, y)

iv_pairwise_set_union(x, y)

iv_pairwise_set_intersect(x, y)

iv_pairwise_set_difference(x, y)

iv_pairwise_set_symmetric_difference(x, y)

Arguments

x, y

⁠[iv]⁠

A pair of interval vectors.

These will be cast to the same type, and recycled against each other.

Value

An iv the same size and type as x and y.

See Also

The non-pairwise versions of these functions, such as iv_set_union().

Examples

x <- iv_pairs(c(1, 3), c(6, 8))
y <- iv_pairs(c(5, 7), c(2, 3))

iv_pairwise_set_complement(x, y)

z <- iv_pairs(c(2, 5), c(4, 7))

iv_pairwise_set_union(x, z)

# Can't take the union when there are gaps
try(iv_pairwise_set_union(x, y))

# But you can force a union across gaps with `iv_pairwise_span()`
iv_pairwise_span(x, y)

iv_pairwise_set_intersect(x, z)

# Can't take an intersection of non-overlapping intervals
try(iv_pairwise_set_intersect(x, y))

iv_pairwise_set_difference(x, z)

# The pairwise symmetric difference function is fairly strict,
# and is only well defined when exactly one of the interval endpoints match
w <- iv_pairs(c(1, 6), c(7, 8))
iv_pairwise_set_symmetric_difference(x, w)

[Package ivs version 0.2.0 Index]