Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

perms

Generate Permutations


Description

Generates all permutations of a vector a.

Usage

perms(a)

Arguments

a

numeric vector of some length n

Details

If a is a vector of length n, generate all permutations of the elements in a as a matrix of size n! x n where each row represents one permutation.

A matrix will be expanded as vector.

Value

matrix of permutations of the elements of a

Note

Not feasible for length(a) > 10.

See Also

Examples

perms(6)
perms(1:6)
perms(c(1, exp(1), pi))

pracma

Practical Numerical Math Functions

v2.3.3
GPL (>= 3)
Authors
Hans W. Borchers [aut, cre]
Initial release
2021-01-22

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.