Generalized transpose of an array

The function aperm(a, perm) may be used to permute an array, a. The argument perm must be a permutation of the integers $\lbrac$ 1, 2, ..., k$\rbrac$, where k is the number of subscripts in a. The result of the function is an array of the same size as a but with old dimension given by perm[j] becoming the new jth dimension. The easiest way to think of this operation is as a generalization of transposition for matrices. Indeed if A is a matrix, (that is, a doubly subscripted array) then B given by

B <- aperm(A, c(2,1))

is just the transpose of A. For this special case a simpler function t() is available, so we could have used B <- t(A).



Jeff Banfield
2/13/1998