subset,VirtualArray-method {via}R Documentation

Subset a 'VirtualArray'-class object

Description

Extract subsets of an object from a class derived from 'VirtualArray' similarly to a regular array.

Usage

## S4 method for signature 'VirtualArray'
subset(x, i, j, ..., oneDim = FALSE, drop = TRUE)

Arguments

x

VirtualArray-class object.

i

subscript of the first dimension(rows) or vector-like subsetting.

j

subscript of the second dimension (columns).

...

subscript of additional dimensions.

oneDim

logical In case of multidimensional VirtualArrays, setting oneDim to TRUE allows the application of one dimensional subscripts.

drop

logical in case the result of subsetting is a single element, should the \codeVirtualArray wrapper be dropped?

Value

Either the same class as x, or the class that forms the element of the VirtualArray.

Examples

ex <- rastex()
# first 4
subset(ex, i=1:4)
# missing at the end
subset(ex, i=1:12)
# character subscript
subset(ex, i=c("a", "b"))
# logical subscript
subs <- rep(TRUE, length(ex))
subs[1] <- FALSE # remove first
subset(ex, i= subs)
# no drop
subset(ex, i=1, drop=FALSE)

[Package via version 0.2.0 Index]