Last data update: 2014.03.03

R: Convert an Array with 4 Dimensions into a Matrix
Array2MatrixR Documentation

Convert an Array with 4 Dimensions into a Matrix

Description

Converts the array, a, with 4 dimensions, c(d1, d2, d3, d4), into a matrix with d1*d2 rows and d3*d4 columns.

Usage

Array2Matrix(a)

Arguments

a

Array with 4 dimensions.

Value

A matrix. If a has the attribute mp, the transformed attribute is returned as well. See ArrayAround for more information about mp.

Author(s)

Florian Gerber, florian.gerber@math.uzh.ch.

See Also

Index, ArrayAround.

Examples

a <- array(data = 1:16, dim = c(2, 2, 2, 2))
Array2Matrix(a = a)
attr(a, "mp") <- c(1, 2, 2, 1)
Array2Matrix(a = a)

Array2Matrix(ArrayAround(data = a, mp = c(1, 1, 1, 1),
                         size = c(1, 1, 2, 2))) 

Results