arrayExtractor: Extracting Information from an Array

Description Usage Arguments Value Note Author(s) References Examples

View source: R/arrayExtractor.R

Description

Uses a list of the same length as the dimensions of an array to extract information, similar to using matrix indexing.

Usage

1
arrayExtractor(inarray, valslist)

Arguments

inarray

The input array.

valslist

A list of vectors to use to extract data. A value of NULL for any of the list elements will return all values for that dimension.

Value

An array.

Note

The list used for valslist must be the same length as the number of dimensions in the array. It must also be specified in the same order as you would normally reference the dimensions of an array. For instance, in the example, the array has row dimensions, column dimensions, and a third dimension.

Author(s)

Ananda Mahto

References

http://stackoverflow.com/q/34795331/1270695

Examples

1
2
3
4
5
6
7
8
my_array <- structure(1:12, .Dim = c(2L, 3L, 2L), 
  .Dimnames = list(c("D_11", "D_12"), 
  c("D_21", "D_22", "D_23"), c("D_31", "D_32")))
my_array

arrayExtractor(my_array, list("D_11", NULL, NULL))
arrayExtractor(my_array, list(NULL, "D_21", "D_32"))
arrayExtractor(my_array, list(NULL, c("D_21", "D_22"), NULL))

mrdwab/SOfun documentation built on June 20, 2020, 6:15 p.m.