Learn R Programming

IntervalQuestionStat (version 0.2.0)

spr: Extract and replace the spreads of interval-valued objects

Description

This functions provides customized access to the spr slot of IntervalData, IntervalList, and IntervalMatrix objects, so their spreads can be extracted and replaced. This does not prevent to use the @ accessor, but does not force others to know the implementation details.

Usage

# S4 method for IntervalData
spr(object)

# S4 method for IntervalList spr(object)

# S4 method for IntervalMatrix spr(object)

# S4 method for IntervalData spr(object) <- value

# S4 method for IntervalList spr(object) <- value

# S4 method for IntervalMatrix spr(object) <- value

Value

On the one hand, spr() function returns the spreads of the intervals contained in IntervalData, IntervalList, or IntervalMatrix instances stored as a single numeric value, a numeric vector, or a matrix object, respectively. On the other hand, spr<- command does not return any value since it only allows to replace the spr slot of the given interval-valued object.

Arguments

object

A single nonempty compact interval or a list or matrix with some intervals of this family, that is, an IntervalData, IntervalList, or IntervalMatrix instance.

value

A numeric or matrix object with the new values of the intervals spreads.

Author

José García-García garciagarjose@uniovi.es

See Also

For accessing mid slot of interval-valued objects, mid() function can be used.

Examples

Run this code
## Some mid() function examples

## With IntervalData
interval <- IntervalData(0, 1)

spr(interval)
spr(interval) <- 0.75
spr(interval)

## With IntervalList
list <- IntervalList(c(1, 3, 5), c(2, 4, 6))

spr(list[c(1, 3)])
spr(list[c(1, 3)]) <- c(1, 3)
spr(list[c(1, 3)])

## With IntervalMatrix
m <- IntervalMatrix(matrix(c(1, 5, 2, 6, 6, 2,
                             7, 3, 3, 4, 4, 5), 2, 6))

spr(m[1, 1])
spr(m[1, 1]) <- 2
spr(m[1, 1])

spr(m[1, 1:2])
spr(m[1, 1:2]) <- c(2, 3)
spr(m[1, 1:2])

spr(m[, c(1, 3)])
spr(m[, c(1, 3)]) <- matrix(1:4, 2, 2)
spr(m[, c(1, 3)])

Run the code above in your browser using DataLab