aperm
From base v3.3
by Rcore Rcore@Rproject.org
Array Transposition
Transpose an array by permuting its dimensions and optionally resizing it.
 Keywords
 array
Usage
aperm(a, perm, ...)
"aperm"(a, perm = NULL, resize = TRUE, ...)
"aperm"(a, perm = NULL, resize = TRUE, keep.class = TRUE, ...)
Arguments
 a
 the array to be transposed.
 perm
 the subscript permutation vector, usually a permutation of
the integers
1:n
, wheren
is the number of dimensions ofa
. Whena
has named dimnames, it can be a character vector of lengthn
giving a permutation of those names. The default (used wheneverperm
has zero length) is to reverse the order of the dimensions.  resize
 a flag indicating whether the vector should be
resized as well as having its elements reordered (default
TRUE
).  keep.class
 logical indicating if the result should be of the
same class as
a
.  ...
 potential further arguments of methods.
Value

A transposed version of array 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.
References
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.
See Also
t
, to transpose matrices.
Examples
library(base)
# interchange the first two subscripts on a 3way 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
Community examples
Looks like there are no examples yet.