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

as-array

Converting Data Frames into Arrays


Description

The as.array for data frames takes all factors in a data frame and uses them to define the dimensions of the resulting array, and fills the array with the values of the remaining numeric variables.

Currently, the data frame must contain all combinations of factor levels.

Usage

## S4 method for signature 'data.frame'
as.array(x,data.name=NULL,...)

Arguments

x

a data frame

data.name

a character string, giving the name attached to the dimension that corresponds to the numerical variables in the data frame (that is, the name attached to the corresponding element of the dimnames list).

...

other arguments, ignored.

Value

An array

Examples

BerkeleyAdmissions <- to.data.frame(UCBAdmissions)
BerkeleyAdmissions
as.array(BerkeleyAdmissions,data.name="Admit")
try(as.array(BerkeleyAdmissions[-1,],data.name="Admit"))

memisc

Management of Survey Data and Presentation of Analysis Results

v0.99.27.3
GPL-2
Authors
Martin Elff (with contributions from Christopher N. Lawrence, Dave Atkins, Jason W. Morgan, Achim Zeileis)
Initial release
2020-11-18

We don't support your browser anymore

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