mid {IntervalQuestionStat}R Documentation

Extract and replace the mid-points of interval-valued objects

Description

This functions provides customized access to the mid slot of IntervalData, IntervalList, and IntervalMatrix objects, so the mid-points of the intervals 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 signature 'IntervalData'
mid(object)

## S4 method for signature 'IntervalList'
mid(object)

## S4 method for signature 'IntervalMatrix'
mid(object)

## S4 replacement method for signature 'IntervalData'
mid(object) <- value

## S4 replacement method for signature 'IntervalList'
mid(object) <- value

## S4 replacement method for signature 'IntervalMatrix'
mid(object) <- value

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 mid-points.

Value

On the one hand, mid() function returns the mid-points 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, mid<- command does not return any value since it only allows to replace the mid slot of the given interval-valued object.

Author(s)

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

See Also

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

Examples

## Some mid() function examples

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

mid(interval)
mid(interval) <- 0.75
mid(interval)

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

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

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

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

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

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


[Package IntervalQuestionStat version 0.2.0 Index]