overlapping_interval: Find the overlapping interval of two ranges.

View source: R/overlapping_interval.R

overlapping_intervalR Documentation

Find the overlapping interval of two ranges.

Description

This function should be applied to cases where the two ranges are inclusive of both endpoints. For example, the function can work for a pair of ranges like [0, 1] and [3, 4] but not for pairs like [0, 1\) and \(3, 5\)

Usage

overlapping_interval(
  interval_1_begin = NULL,
  interval_1_end = NULL,
  interval_2_begin = NULL,
  interval_2_end = NULL
)

Arguments

interval_1_begin

a number at which the first interval begins (the left INCLUSIVE endpoint of interval 1)

interval_1_end

a number at which the first interval ends (the right INCLUSIVE endpoint of interval 1)

interval_2_begin

a number at which the second interval begins (the left INCLUSIVE endpoint of interval 2)

interval_2_end

a number at which the second interval ends (the right INCLUSIVE endpoint of interval 2)

Value

the output will be NULL if there is no overlapping region or a vector of the endpoints of the overlapping interval.

Examples

overlapping_interval(1, 3, 2, 4)
overlapping_interval(1, 2.22, 2.22, 3)

kim documentation built on Oct. 9, 2023, 5:08 p.m.