lexicographicPermutation {R.basic}R Documentation

Generate the n:th lexicographic permutation of a vector

Description

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.

Usage

  lexicographicPermutation(x, n)

Arguments

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.

Value

Returns a permuted vector of the same length as the input vector.

Author(s)

Henrik Bengtsson, http://www.braju.com/R/

See Also

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.

Examples

See help(lexicographicPermutations) for an example.

[Package Contents]