permn                package:combinat                R Documentation

_G_e_n_e_r_a_t_e_s _a_l_l _p_e_r_m_u_t_a_t_i_o_n_s _o_f _t_h_e _e_l_e_m_e_n_t_s _o_f _x

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

     Generates all permutations of the elements of x, in a minimal-
     change order. If x is a positive integer,  returns all
     permutations of the elements of seq(x). If argument "fun" is not
     null,  applies a function given by the argument to each point.
     "..." are passed unchanged to the function given by argument fun,
     if any.

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

     permn(x, fun=NULL, ...)

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

       x: vector 

     fun: if non.null, applied at each perm 

     ...: args passed to fun 

_D_e_t_a_i_l_s:

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

     list: each component is either a permutation, or the results of
     applying fun to a permutation

_R_e_f_e_r_e_n_c_e_s:

     Reingold, E.M., Nievergelt, J., Deo, N. (1977) Combinatorial
     Algorithms: Theory and Practice. NJ: Prentice-Hall. pg. 170.

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

     sample, fact, combn, hcube, xsimplex

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

         # Convert output to a matrix of dim c(6, 720)
          t(array(unlist(permn(6)), dim = c(6, gamma(7))))
            # A check that every element occurs the same number of times in each
            # position
            apply(t(array(unlist(permn(6)), dim = c(6, gamma(7)))), 2, tabulate,
                    nbins = 6)

            # Apply, on the fly, the diff function to every permutation
            t(array(unlist(permn(6, diff)), dim = c(5, gamma(7))))

