subarray(x, value, drop = TRUE)
subtable(x, variables, value, drop = TRUE)
Arguments
x
An array.
variables
An integer vector containing the dimensions of x to subset.
value
A list or vector containing values to retain.
drop
Logical indicating whether dimensions with only 1 retained should be dropped. Defaults to TRUE.
Value
Returns an array of dimension sapply(value, length) if drop=TRUE, otherwise specified dimensions of size 1 are dropped. Dimensions which are unspecified in subtable are never dropped.
Details
Essentially just allows more flexible calls of [ on an array.
subarray requires the values for each dimension should be specified, so for a $2 \times 2 \times 2$ array x, subarray(x, list(1,2,1:2)) is just x[1,2,1:2].
subtable allows unspecified dimensions to be retained automatically. Thus, for example subtable(x, c(2,3), list(1, 1:2)) is x[,1,1:2].