aperm                  package:base                  R Documentation

_A_r_r_a_y _T_r_a_n_s_p_o_s_i_t_i_o_n

_D_e_s_c_r_i_p_t_i_o_n:

     Transpose an array by permuting its dimensions and optionally
     resizing it.

_U_s_a_g_e:

     aperm(a, perm, resize = TRUE)

_A_r_g_u_m_e_n_t_s:

       a: the array to be transposed.

    perm: the subscript permutation vector, which must be a permutation
          of the integers `1:n', where `n' is the number of dimensions
          of `a'.  The default 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').

_V_a_l_u_e:

     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 `FALSE' then the returned object
     has the same dimensions as `a', and the dimnames are dropped.

     The function `t' provides a faster and more convenient way of
     transposing matrices.

_A_u_t_h_o_r(_s):

     Jonathan Rougier, J.C.Rougier@durham.ac.uk did the faster C
     implementation.

_S_e_e _A_l_s_o:

     `t', to transpose matrices.

_E_x_a_m_p_l_e_s:

     # 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])

