Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

a2la

(3D+) Array to List of (3D+) Arrays


Description

a2la converts an (3D+) array to a list of (3D+) arrays. This function is a simple wrapper for asplit(x = a, MARGIN = along).

Usage

a2la(a, along = ndim(a), check = TRUE)

Arguments

a

(3D+) array

along

integerish vector of length 1 specifying the dimension to split the array along. Default is the last dimension of a.

check

logical vector of length 1 specifying whether to check the structure of the input arguments. For example, check whether a is a 3D+ array. This argument is available to allow flexibility in whether the user values informative error messages (TRUE) vs. computational efficiency (FALSE).

Value

list of arrays where each array is one dimension less than a and the names of the list are dimnames(a)[[along]].

Examples

# without dimnames
a <- abind::abind(HairEyeColor*1, HairEyeColor*2, HairEyeColor*3, along = 4L)
a2la(a)
# with dimnames
a <- abind::abind("one" = HairEyeColor*1, "two" = HairEyeColor*2,
   "three" = HairEyeColor*3, along = 4L)
a2la(a)
a2la(a, along = 1) # along = 1

str2str

Convert R Objects from One Structure to Another

v0.1.1
GPL (>= 2)
Authors
David Disabato [aut, cre]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.