| 1 |
\name{as.array} |
| 2 |
\alias{as.array} |
| 3 |
\alias{as.array,data.frame-method} |
| 4 |
\title{Converting Data Frames into Arrays} |
| 5 |
\description{ |
| 6 |
The \code{as.array} for data frames |
| 7 |
takes all factors in a data frame and uses them |
| 8 |
to define the dimensions of the resulting array, |
| 9 |
and fills the array with the values of |
| 10 |
the remaining numeric variables. |
| 11 |
|
| 12 |
Currently, the data frame must contain all |
| 13 |
combinations of factor levels. |
| 14 |
} |
| 15 |
\usage{ |
| 16 |
\S4method{as.array}{data.frame}(x,data.name=NULL,\dots) |
| 17 |
} |
| 18 |
\arguments{ |
| 19 |
\item{x}{a data frame} |
| 20 |
\item{data.name}{ |
| 21 |
a character string, giving the name |
| 22 |
attached to the dimension |
| 23 |
that corresponds to the |
| 24 |
numerical variables in the data frame |
| 25 |
(that is, the \code{name} attached to |
| 26 |
the corresponding element of the |
| 27 |
\code{dimnames} list). |
| 28 |
} |
| 29 |
\item{\dots}{other arguments, ignored.} |
| 30 |
} |
| 31 |
\value{ |
| 32 |
An array |
| 33 |
} |
| 34 |
\examples{ |
| 35 |
BerkeleyAdmissions <- to.data.frame(UCBAdmissions) |
| 36 |
BerkeleyAdmissions |
| 37 |
as.array(BerkeleyAdmissions,data.name="Admit") |
| 38 |
try(as.array(BerkeleyAdmissions[-1,],data.name="Admit")) |
| 39 |
} |