extract_dim {listarrays} | R Documentation |
Extract with [
on a specified dimension
Description
Extract with [
on a specified dimension
Usage
extract_dim(X, which_dim, idx, drop = NULL, depth = Inf)
extract_rows(X, idx, drop = NULL, depth = Inf)
extract_cols(X, idx, drop = NULL, depth = Inf)
Arguments
X |
Typically, an array, but any object with a |
which_dim |
A scalar integer or character, specifying the dimension to extract from |
idx |
A numeric, boolean, or character vector to perform subsetting with. |
drop |
Passed on to |
depth |
Scalar number, how many levels to recurse down if |
Examples
# extract_rows is useful to keep the same code path for arrays of various sizes
X <- array(1:8, c(4, 3, 2))
y <- c("a", "b", "c", "d")
(Y <- onehot(y))
extract_rows(X, 2)
extract_rows(Y, 2)
extract_rows(y, 2)
library(zeallot)
c(X2, Y2, y2) %<-% extract_rows(list(X, Y, y), 2)
X2
Y2
y2
[Package listarrays version 0.4.0 Index]