Learn R Programming

latte (version 0.2.1)

vec2tab: Vector to array conversion

Description

Convert a vector into an array given a set of dimensions; it therefore simply wraps aperm() and array().

Usage

vec2tab(vec, dim)

Value

An array

Arguments

vec

A vector

dim

The desired array dimensions, oftentimes a vector of the number of levels of each variable in order

Details

This function converts an array (or a multi-way contingency table) into a vector, using a consistent ordering of the cells. The ordering of the cells is lexicographical and cannot be specified by the user.

See Also

tab2vec(), aperm(), array()

Examples

Run this code

data(Titanic)
Titanic
tab2vec(Titanic)
vec2tab(tab2vec(Titanic), dim(Titanic))
vec2tab(tab2vec(Titanic), dim(Titanic)) == Titanic
all(vec2tab(tab2vec(Titanic), dim(Titanic)) == Titanic)


Run the code above in your browser using DataLab