Skip to contents

iv_pairwise_span() computes the pairwise "span" between the i-th interval of x and the i-th interval of y. The pairwise span of two intervals is a new interval containing the minimum start and maximum end of the original intervals. It is similar to iv_pairwise_set_union(), except it fills across gaps.

Usage

iv_pairwise_span(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.

Examples

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

# Can't take the set union when there are gaps
try(iv_pairwise_set_union(x, y))
#> Error in iv_pairwise_set_union(x, y) : 
#>   Can't take the union of intervals containing a gap.
#>  Location 1 contains a gap.
#>  Use `iv_pairwise_span()` to combine across gaps.

# But you can compute the span of the intervals
iv_pairwise_span(x, y)
#> <iv<double>[2]>
#> [1] [1, 7) [2, 8)