R: Compute interval sizes

size {intervals} | R Documentation

## Compute interval sizes

### Description

Compute the size, in either Z or R as appropriate, for each interval in an interval matrix.

### Usage

    ## S4 method for signature 'Intervals'
    size(x, as = type(x))

    ## S4 method for signature 'Intervals_full'
    size(x, as = type(x))

### Arguments

`x` | An `"Intervals"` or `"Intervals_full"` object.
`as` | Should the intervals be thought of as in Z or R? This is usually determined automatically from the `type` slot, but because changing type may cause object copying, it is sometimes convenient to temporarily override this slot without actually resetting it.

### Details

For type `"Z"` objects, counting measure; for type `"R"` objects, Lebesgue measure. For type `"Z"` objects, intervals of form (a,a] and (a,a) are both of length 0.

### Value

A numeric vector with length equal to `nrow(x)`.

### See Also

See `empty` to identify empty intervals. Note that when `type(x) == "R"`, a size of 0 does not imply that an interval is empty.

### Examples

    z1 <- Intervals( cbind( 1, 1:3 ), type = "Z" )
    z2 <- z1; closed(z2)[1] <- FALSE
    z3 <- z1; closed(z3) <- FALSE

    size(z1)
    size(z2)
    size(z3)

    r1 <- z1; type(r1) <- "R"
    r2 <- z2; type(r2) <- "R"
    r3 <- z3; type(r3) <- "R"

    size(r1)
    size(r2)
    size(r3)

    s1 <- Intervals_full( matrix( 1, 3, 2 ), type = "Z" )
    closed(s1)[2,2] <- FALSE
    closed(s1)[3,] <- FALSE

    size(s1)

[Package intervals version 0.15.2 Index]