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

slice-methods

Slice a vector-like or list-like object


Description

slice is a generic function that creates views on a vector-like or list-like object that contain the elements that are within the specified bounds.

Usage

slice(x, lower=-Inf, upper=Inf, ...)

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

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

Arguments

x

An Rle or RleList object, or any object coercible to an Rle object.

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.

...

Additional arguments to be passed to specific methods.

Details

slice is useful for finding areas of absolute maxima (peaks), absolute minima (troughs), or fluctuations within specified limits. One or more view summarization methods can be used on the result of slice. See ?`link{view-summarization-methods}`

Value

The method for Rle objects returns an RleViews object if rangesOnly=FALSE or an IRanges object if rangesOnly=TRUE.

The method for RleList objects returns an RleViewsList object if rangesOnly=FALSE or an IRangesList object if rangesOnly=TRUE.

Author(s)

P. Aboyoun

See Also

Examples

## Views derived from coverage
x <- IRanges(start=c(1L, 9L, 4L, 1L, 5L, 10L),
             width=c(5L, 6L, 3L, 4L, 3L,  3L))
cvg <- coverage(x)
slice(cvg, lower=2)
slice(cvg, lower=2, rangesOnly=TRUE)

IRanges

Foundation of integer range manipulation in Bioconductor

v2.24.1
Artistic-2.0
Authors
H. Pagès, P. Aboyoun and M. Lawrence
Initial release

We don't support your browser anymore

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