# close_intervals-methods: Re-represent integer intervals with open or closed endpoints In intervals: Tools for working with points and intervals

## Description

Given an integer interval matrix, adjust endpoints so that all intervals have the requested closure status.

## Usage

 1 2 3 4 5 6 7 8 9 10 11 ## S4 method for signature 'Intervals_virtual' close_intervals(x) ## S4 method for signature 'Intervals_virtual' open_intervals(x) ## S4 method for signature 'Intervals' adjust_closure(x, close_left = TRUE, close_right = TRUE) ## S4 method for signature 'Intervals_full' adjust_closure(x, close_left = TRUE, close_right = TRUE)

## Arguments

 x An object of appropriate class, and for which [email protected] == "Z". If [email protected] == "R", an error is generated. close_left Should the left endpoints be closed or open? close_right Should the right endpoints be closed or open?

## Value

An object of the same class as x, with endpoints adjusted as necessary and all closed(x) set to either TRUE or FALSE, as appropriate.

## Note

The close_intervals and open_intervals are for convenience, and just call adjust_closure with the approriate arguments.

The x object may contain empty intervals, with at least one open endpoint, and still be valid. (Intervals are invalid if their second endpoint is less than their first.) The close_intervals method would, in such cases, create an invalid result; to prevent this, empty intervals are detected and removed, with a warning.

This package does not make a distinction between closed and open infinite endpoints: an interval with an infinite endpoint extends to (plus or minus) infinity regardless of the closure state. For example, distance_to_nearest will return a 0 when Inf is compared to both "[0, Inf)" and "[0, Inf]".

## Examples

 1 2 3 4 5 6 7 8 9 10 11 12 13 14 x <- Intervals( c( 1, 5, 10, 1, 6, 20 ), closed = c( TRUE, FALSE ), type = "Z" ) # Empties are dropped close_intervals(x) adjust_closure(x, FALSE, TRUE) # Intervals_full y <- as( x, "Intervals_full" ) closed(y)[1,2] <- TRUE open_intervals(y)

intervals documentation built on May 31, 2017, 2:35 a.m.