| lexicographicPermutation {R.basic} | R Documentation |
Generate the n:th lexicographic permutations of a vector. The 0:th permutation is the non-permuted vector. The last permutation is the (n-1):th. If the vector is of length N, there are N! permutation.
lexicographicPermutation(x, n)
x |
The vector from which the permutation should be generated. |
n |
Integer between 0 and N!-1, where N is the
length of the vector. If n==0 the non-permutated vector is
returned. |
Returns a permuted vector of the same length as the input vector.
Henrik Bengtsson, http://www.braju.com/R/
See lexicographicPermutations() to generate all
lexicographic permutations of a vector.
See permutations() for a wrapper function to generate
different types of permutations.
See x[sample(n)] to generate a random permutation.
See help(lexicographicPermutations) for an example.