indexArray: Select along one dimension in multidimensional array

Description Usage Arguments Value References Examples

View source: R/utils.R

Description

Select along one dimension in multidimensional array

Usage

1
indexArray(x, dim, value, drop = TRUE, verbose = FALSE)

Arguments

x

array.

dim

integer. Dimension along which to select one hyperplane.

value

integer. Hyperplane to select from given dimension.

drop

logical. For matrices and arrays. If TRUE the result is coerced to the lowest possible dimension.

verbose

logical. Print out equivalent command using '[' operator.

Value

array or vector.

References

https://stackoverflow.com/a/14502298.

Examples

1
2
3
4
5
A <- array(data = 1:24, dim = c(2, 3, 4), dimnames = list(c("x1", "x2"), c("y1", "y2", "y3"), NULL))
identical(indexArray(A, 1, 1), A[1, , ])
identical(indexArray(A, 1, 1, drop = FALSE), A[1, , , drop = FALSE])
identical(indexArray(A, 1, 2), A[2, , ])
identical(indexArray(A, 2, 3), A[, 3, ])

bentyeh/r_bentyeh documentation built on Jan. 1, 2021, 4:59 p.m.