An array can be considered as a multiply subscripted collection of data entries. This section provides details on the construction and manipulation of arrays.
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 {1, …, k}, 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 j
-th 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).