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

Vector2Array

Transforming a vector to an array


Description

Transform a vector into a multidimensional array. The transformation is done assuming that the last index of the array moves fastest. For instance, the relation between a vector v of lenght 8 and an array a of dimensions (2,2,2) is defined by v = ( a[1,1,1], a[1,1,2], a[1,1,3], a[1,2,1], a[1,2,2], …,a[3,3,3] ).

Usage

Vector2Array(vect, dim.out)

Arguments

vect

The vector of length one or more to be transformed into an array.

dim.out

The dimension attribute for the array to be created, that is an integer vector of length one or more giving the maximal indices in each dimension.

Value

An array of dimensions given by dim.out filled with the data from the input vector vec.

Author(s)

Thomas Suesse.

Maintainer: Johan Barthelemy johan@uow.edu.au.

See Also

The inverse transformation is performed with the function Array2Vector.

Examples

# generate a vector [1,2,...,27]
v <- seq(1:27)
# transform it into an array of dimension (3,3,3)
a <- Vector2Array(v,c(3,3,3))

mipfp

Multidimensional Iterative Proportional Fitting and Alternative Models

v3.2.1
GPL-2
Authors
Johan Barthelemy [aut, cre], Thomas Suesse [aut], Mohammad Namazi-Rad [ctb]
Initial release
2018-08-29

We don't support your browser anymore

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