Last chance! 50% off unlimited learning
Sale ends in
aperm(a, perm, ...)
"aperm"(a, perm = NULL, resize = TRUE, ...)
"aperm"(a, perm = NULL, resize = TRUE, keep.class = TRUE, ...)
1:n
, where n
is the number of dimensions
of a
. When a
has named dimnames, it can be a
character vector of length n
giving a permutation of those
names. The default (used whenever perm
has zero length) is to
reverse the order of the dimensions.TRUE
).a
.a
, with subscripts permuted as
indicated by the array perm
. If resize
is TRUE
,
the array is reshaped as well as having its elements permuted, the
dimnames
are also permuted; if resize = FALSE
then the
returned object has the same dimensions as a
, and the dimnames
are dropped. In each case other attributes are copied from a
.The function t
provides a faster and more convenient way of
transposing matrices.
t
, to transpose matrices.
# interchange the first two subscripts on a 3-way array x
x <- array(1:24, 2:4)
xt <- aperm(x, c(2,1,3))
stopifnot(t(xt[,,2]) == x[,,2],
t(xt[,,3]) == x[,,3],
t(xt[,,4]) == x[,,4])
UCB <- aperm(UCBAdmissions, c(2,1,3))
UCB[1,,]
summary(UCB) # UCB is still a continency table
Run the code above in your browser using DataLab