slice-methods: Slice an XInteger or XDouble object

Description Usage Arguments Value Author(s) See Also Examples

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## 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

1
2
3
4
5
6
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 documentation built on Nov. 8, 2020, 5:19 p.m.