Returns a matrix containing all permutations of the integers 1:n (one permutation per row).

permutations(n)

Arguments

n

Number of element to permute.

Author

Friedrich Leisch

Examples

permutations(3)
#>      [,1] [,2] [,3]
#> [1,]    1    2    3
#> [2,]    2    1    3
#> [3,]    2    3    1
#> [4,]    1    3    2
#> [5,]    3    1    2
#> [6,]    3    2    1