Reshape an array to send a dimension forward or back

set_as_rows(X, which_dim)

set_as_cols(X, which_dim)

Arguments

X

an array

which_dim

scalar integer or string, which dim to bring forward. Negative numbers count from the back

This is a powered by base::aperm().

Value

a reshaped array

See also

Examples

x <- array(1:24, 2:4) y <- set_as_rows(x, 3) for (i in seq_along_dim(x, 3)) stopifnot( identical(x[,,i], y[i,,]) )