Description Usage Arguments Value Examples
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.
1 2 |
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 |
... |
other arguments, ignored. |
An array
1 2 3 4 | BerkeleyAdmissions <- to.data.frame(UCBAdmissions)
BerkeleyAdmissions
as.array(BerkeleyAdmissions,data.name="Admit")
try(as.array(BerkeleyAdmissions[-1,],data.name="Admit"))
|
Loading required package: lattice
Loading required package: MASS
Attaching package: 'memisc'
The following objects are masked from 'package:stats':
contr.sum, contr.treatment, contrasts
The following object is masked from 'package:base':
as.array
Gender Dept Admitted Rejected
1 Male A 512 313
2 Female A 89 19
3 Male B 353 207
4 Female B 17 8
5 Male C 120 205
6 Female C 202 391
7 Male D 138 279
8 Female D 131 244
9 Male E 53 138
10 Female E 94 299
11 Male F 22 351
12 Female F 24 317
, , Dept = A
Gender
Admit Male Female
Admitted 512 89
Rejected 313 19
, , Dept = B
Gender
Admit Male Female
Admitted 353 17
Rejected 207 8
, , Dept = C
Gender
Admit Male Female
Admitted 120 202
Rejected 205 391
, , Dept = D
Gender
Admit Male Female
Admitted 138 131
Rejected 279 244
, , Dept = E
Gender
Admit Male Female
Admitted 53 94
Rejected 138 299
, , Dept = F
Gender
Admit Male Female
Admitted 22 24
Rejected 351 317
Error : cannot transform 'x' into an array
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.