close_intervals | R Documentation |
Given an integer interval matrix, adjust endpoints so that all intervals have the requested closure status.
## 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)
x |
An object of appropriate class, and for which |
close_left |
Should the left endpoints be closed or open? |
close_right |
Should the right endpoints be closed or open? |
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.
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]"
.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.