01_subsetting_operators: Subsetting Operators

Description Usage Arguments Details See Also Examples

Description

Subsetting operators for vector-like objects.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
## S3 method for class 'ObjectArray'
v[...]
## S3 method for class 'ObjectArray'
v[[...]]
## S3 replacement method for class 'ObjectArray'
v[[...]] <- value

## S3 method for class 'NestMatrix'
v[[i, j, ..., drop=TRUE, zero=TRUE]]
## S3 replacement method for class 'NestMatrix'
v[[i, j]] <- value

## S3 method for class 'PartMatrix'
v[[i, j, ..., drop=TRUE]]
## S3 replacement method for class 'PartMatrix'
v[[i, j]] <- value

## S3 method for class 'GeomArray'
v[...]
## S3 method for class 'ImageArray'
v[...]
## S3 method for class 'MatrixArray'
v[...]
## S3 replacement method for class 'GeomArray'
v[[...]] <- value

#for SectMatrix
getSect (v, ..., drop=TRUE)

Arguments

v

An ObjectArray (including subclasses) or block matrix object.

i, j, ...

The indices.

drop

Logical, if true, reduce the number of dimensions, where possible.

zero

Logical, if true, replace ZERO with zero, or a zero matrix.

value

A suitable value to assign.

Details

ObjectArray (and NestMatrix), are similar to lists, so:
Single bracket subsetting returns another ObjectArray, which is a subset of the original.
Double bracket subsetting gets or sets a single element within the ObjectArray.

For PartMatrix:
Currently, single bracket subsetting is not supported.
Currently, double bracket subsetting indexes a single submatrix.

Note that the number of indices used in an ObjectArray depends on the number of dimensions.

The number of indices in PartMatrix objects is always two.
And the number of indices for SectMatrix subsetting depends on the VMap object.

Note that there are restrictions on what can be assigned:
An ObjectArray may be restricted by its CLASS slot, determined when the object is constructed.
Other objects may have restrictions on the sizes of submatrices.

See Also

ObjectArray

NestMatrix

PartMatrix

SectMatrix

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
x <- matrix (1:16, 4, 4)

pm <- as.PartMatrix (x, 2, 2)
nm <- as.NestMatrix (pm)

#all same
x [1:2, 1:2]
nm [[1, 1]]
pm [[1, 1]]

#all same
x [1, 2]
nm [[1, 1]][1, 2]
pm [[1, 1]][1, 2]

vectools documentation built on June 7, 2021, 9:08 a.m.