unwrap.array: Unwrap an array, matrix or a vector to an array of more...

unwrap.arrayR Documentation

Unwrap an array, matrix or a vector to an array of more dimensions

Description

Unwrap an array, matrix or a vector to an array of more dimensions. This is done by splitting up each dimension into several dimension based on the names of that dimension.

Usage

## S3 method for class 'array'
unwrap(x, split=rep("[.]", length(dim(x))), drop=FALSE, ...)

Arguments

x

An array or a matrix.

split

A list or a character vector. If a list, it should contain functions that takes a character vector as the first argument and optional ... arguments. Each function should split the vector into a list of same length and where all elements contains the same number of parts. If a character vector, each element split[i] is replaced by a function call function(names, ...) strsplit(names, split=split[i]).

drop

If TRUE, dimensions of of length one are dropped, otherwise not.

...

Arguments passed to the split functions.

Details

Although not tested thoroughly, unwrap() should be the inverse of wrap() such that identical(unwrap(wrap(x)), x) holds.

Value

Returns an array.

Author(s)

Henrik Bengtsson

See Also

*wrap().

Examples

## Not run: See ?wrap.array for an example

R.utils documentation built on Nov. 18, 2023, 1:09 a.m.