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

