Learn R Programming

kStatistics (version 2.0)

nPerm: Complete enumeration of all possible permutations

Description

The function returns all possible different permutations of objects in a list or in a vector.

Usage

nPerm(L = c())

Arguments

L

List/Vector

Value

list

all permutations of L

Details

In order to manage permutations of numbers or vectors, the standard permutation process is applied.

References

Charalambides C. A. (2002) Enumerative Combinatoris, Chapman & Haii/CRC.

Examples

Run this code
# NOT RUN {
# permutations of 1,2,3  
nPerm( c(1,2,3) );

# permutations of 1,2,1 (two elements are equal) 
nPerm( c(1,2,1) );

# permutations of the words "Alice", "Box","Jack"
nPerm( c("Alice", "Box","Jack") );

# permutations of the vectors c(0,1), c(2,3), c(7,3)
nPerm( list(c(0,1), c(2,3), c(7,3)) );
# }

Run the code above in your browser using DataLab