Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

slice-methods

Slice an XInteger or XDouble object


Description

The slice methods for XInteger and XDouble objects create views corresponding to the indices where the data are within the specified bounds. The views are returned in a XIntegerViews or XDoubleViews object.

Usage

## S4 method for signature 'integer'
slice(x, lower=-.Machine$integer.max, upper=.Machine$integer.max)

## S4 method for signature 'XInteger'
slice(x, lower=-.Machine$integer.max, upper=.Machine$integer.max)

## S4 method for signature 'numeric'
slice(x, lower=-Inf, upper=Inf,
      includeLower=TRUE, includeUpper=TRUE, rangesOnly=FALSE)

## S4 method for signature 'XDouble'
slice(x, lower=-.Machine$double.xmax, upper=.Machine$double.xmax,
      includeLower=TRUE, includeUpper=TRUE, rangesOnly=FALSE)

Arguments

x

An XInteger or XDouble object. Alternatively, it can also be an integer or numeric vector.

lower, upper

The lower and upper bounds for the slice.

includeLower, includeUpper

Logical indicating whether or not the specified boundary is open or closed.

rangesOnly

A logical indicating whether or not to drop the original data from the output.

Value

An XIntegerViews or XDoubleViews object if rangesOnly=FALSE.

An IRanges object if rangesOnly=TRUE.

Author(s)

P. Aboyoun

See Also

Examples

vec <- as.integer(c(19, 5, 0, 8, 5))
slice(vec, lower=5, upper=8)

set.seed(0)
vec <- sample(24)
slice(vec, lower=4, upper=16)

XVector

Foundation of external vector representation and manipulation in Bioconductor

v0.30.0
Artistic-2.0
Authors
Hervé Pagès and Patrick Aboyoun
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.