`"Intervals"`

objects are two-column matrices which represent
sets, possibly non-disjoint and in no particular order, of intervals
on either the integers or the real line. All intervals in each object
have the same endpoint closure pattern. `"Intervals_full"`

objects are similar, but permit interval-by-interval endpoint closure
specification.

Objects can be created by calls of the form ```
new("Intervals",
...)
```

, or better, by using the constructor functions
`Intervals(...)`

and
`Intervals_full(...)`

.

`.Data`

:See

`"Intervals_virtual"`

.`closed`

:-
For

`"Intervals"`

objects, a two-element logical vector. For`"Intervals_full"`

objects, a two-column logical matrix with the same dimensions as`.Data`

. If omitted in a`new`

call, the`closed`

slot will be initialized to an object of appropriate type and size, with all entries`TRUE`

. If`closed`

is a vector of length 1, or a vector of length 2 for the`"Intervals_full"`

class, an appropriate object will be made by reusing the supplied values row-wise. See the example below. `type`

:See

`"Intervals_virtual"`

.

Class `"Intervals_virtual"`

, directly.

Class `"matrix"`

, by class
`"Intervals_virtual"`

, distance 2.

Class `"array"`

, by class
`"Intervals_virtual"`

, distance 3.

Class `"structure"`

, by class
`"Intervals_virtual"`

, distance 4.

Class `"vector"`

, by class
`"Intervals_virtual"`

, distance 5, with explicit coerce.

As of R 2.8.1, it still does not seem possible to write S4 methods for
`rbind`

or `c`

. To concatenate sets of intervals into a
single sets, the S3 methods `c.Intervals`

and
`c.Intervals_full`

are provided. While `rbind`

might
seem more natural, its S3 dispatch is non-standard and it could not be
used. Both methods are documented separately.

- [
`signature(x = "Intervals")`

- [
`signature(x = "Intervals_full")`

- [<-
`signature(x = "Intervals", i = "ANY", j = "missing", value = "Intervals_virtual")`

- [<-
`signature(x = "Intervals_full", i = "ANY", j = "missing", value = "Intervals_virtual")`

- adjust\_closure
`signature(x = "Intervals")`

- adjust\_closure
`signature(x = "Intervals_full")`

- closed<-
`signature(x = "Intervals")`

- closed<-
`signature(x = "Intervals_full")`

- coerce
`signature(from = "Intervals", to = "Intervals_full")`

- coerce
`signature(from = "Intervals_full", to = "Intervals")`

- empty
`signature(x = "Intervals")`

- empty
`signature(x = "Intervals_full")`

- initialize
`signature(.Object = "Intervals")`

- initialize
`signature(.Object = "Intervals_full")`

- size
`signature(x = "Intervals")`

- size
`signature(x = "Intervals_full")`

Validity checking takes place when, for example, using the
`type<-`

replacement accessor: if one attempts to set type to
`"Z"`

but the endpoint matrix contains non-integer values, an
error is generated. Because accessors are not used for the endpoint
matrix itself, though, it is possible to create invalid `"Z"`

objects by setting endpoints to inappropriate values.

We do not currently permit an integer data type for the endpoints
matrix, even when `type == "Z"`

, because this creates
complications when taking complements – which is most easily handled
through the use of `-Inf`

and `Inf`

. This is particularly
awkward for objects of class `"Intervals"`

, since current endpoint
closure settings may not permit inclusion of the minimal/maximal
integer. This issue may be addressed, however, in future updates. (We
do, however, check that endpoints are congruent to 0 mod 1 when
`type == "Z"`

.)

When creating object, non-matrix endpoint sources will be converted to
a two-column matrix, for convenience. Recycling is supported for the
`closed`

slot when creating new objects.

See `"Intervals_virtual"`

.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | ```
# The "Intervals" class
i <- Intervals(
matrix(
c(1,2,
3,5,
4,6,
8,9
),
byrow = TRUE,
ncol = 2
),
closed = c( TRUE, TRUE ),
type = "Z"
)
# Row subsetting preserves class. Column subsetting causes coercion to
# "matrix" class.
i
i[1:2,]
i[,1:2]
# Full endpoint control
j <- as( i, "Intervals_full" )
closed(j)[ 3:4, 2 ] <- FALSE
closed(j)[ 4, 1 ] <- FALSE
j
# Rownames may be used
rownames(j) <- c( "apple", "banana", "cherry", "date" )
j
# Assignment preserves class, coercing if necessary
j[2:3] <- i[1:2,]
j
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.