splitAlongDim: Split Array Along a Dimension

View source: R/array.R

splitAlongDimR Documentation

Split Array Along a Dimension

Description

Split an array along its n-th dimension. The implementation was found here: https://stackoverflow.com/questions/20198751/three-dimensional-array-to-list

Usage

splitAlongDim(a, n)

Arguments

a

an array

n

number of the dimension along which to split the array

Value

array of one dimension less than a

Examples

# Define an array
A <- array(1:8, dim = c(2, 2, 2), dimnames = list(
  paste0("x", 1:2), paste0("y", 1:2), paste0("z", 1:2)
))

splitAlongDim(A, 1)
splitAlongDim(A, 2)
splitAlongDim(A, 3)


KWB-R/kwb.utils documentation built on April 1, 2024, 7:12 a.m.