Learn R Programming

str2str (version 0.2.1)

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)

Value

list of arrays where each array is one dimension less than a

and the names of the list are dimnames(a)[[along]].

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).

Examples

Run this code
# 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

Run the code above in your browser using DataLab