permutations: generate all permutations of 1 to n

View source: R/simulate.R

permutationsR Documentation

generate all permutations of 1 to n

Description

Copied from Museful's solution from here https://stackoverflow.com/questions/11095992/generating-all-distinct-permutations-of-a-list-in-r This also mimics RcppAlgos::permuteGeneral(n,n)

Usage

permutations(n)

Arguments

n

an integer

Value

a matrix of n columns and factorial(n) rows

Examples

permutations(3)


zhenkewu/lotR documentation built on April 24, 2022, 2:36 a.m.