\Header{aperm}{Array Transposition}
\keyword{array}{aperm}
\begin{Description}\relax
Transpose an array by permuting its dimensions and optionally resizing
it.\end{Description}
\begin{Usage}
\begin{verbatim}
aperm(a, perm, resize = TRUE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{a}] the array to be transposed.
\item[\code{perm}] the subscript permutation vector, which must be a
permutation of the integers \code{1:n}, where \code{n} is the
number of dimensions of \code{a}.  The default is to reverse the
order of the dimensions.
\item[\code{resize}] a flag indicating whether the vector should be
resized as well as having its elements reordered (default \code{TRUE}).
\end{ldescription}
\end{Arguments}
\begin{Value}
A transposed version of array \code{a}, with subscripts permuted as
indicated by the array \code{perm}.  If \code{resize} is \code{TRUE},
the array is reshaped as well as having its elements permuted, the
\code{dimnames} are also permuted;
if \code{FALSE} then the returned object has the same dimensions as
\code{a}, and the dimnames are dropped.

The function \code{t} provides a faster and more convenient way of
transposing matrices.\end{Value}
\begin{Author}\relax
Jonathan Rougier, \email{J.C.Rougier@durham.ac.uk} did the
faster C implementation.\end{Author}
\begin{References}\relax
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
\emph{The New S Language}.
Wadsworth \& Brooks/Cole.\end{References}
\begin{SeeAlso}\relax
\code{\Link{t}}, to transpose matrices.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
# 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])

\end{ExampleCode}
\end{Examples}

