Skip to contents

Intervals

Usage

interval(
  range = c(-Inf, Inf),
  ...,
  include_lowest = closed,
  include_highest = closed,
  closed = FALSE,
  integer = FALSE,
  read_only = FALSE
)

is.Interval(x)

Arguments

range

The interval boundaries as a sorted two-element numeric vector.

...

First argument is used as the endpoint if range has length 1. Additional arguments, or any if range has length 2, cause a warning and will be ignored.

include_lowest

Is the lower boundary part of the interval?

include_highest

Is the upper boundary part of the interval?

closed

Is the interval closed?

integer

Is the interval only over the integers?

read_only

Make the interval object read-only?

x

An object.

Value

interval returns an Interval. is.Interval returns TRUE if x is an Interval, FALSE otherwise.

See also

interval-operations

Examples

# The real line
interval()
#> (-Inf, Inf)

# Closed unit interval
interval(c(0, 1), closed = TRUE)
#> [0, 1]
# Alternative form
interval(0, 1, closed = TRUE)
#> [0, 1]

# Non-negative real line
interval(c(0, Inf), include_lowest = TRUE)
#> [0, Inf)