SourceSet (version 0.1.0)

getPermutations: Get random permutations of a set of elements

Description

The function arranges, in an optimized way, all the elements of a set into a selected number of different sequences (i.e., permutations). If the number of possible orderings is less than the required number, the function returns the collection of all possible permutations.

Usage

getPermutations(n, nperms)

Arguments

n

number of elements

nperms

number of required permutations

Value

The function returns:

  • perms: a matrix with nperms rows and n columns, containing the sequence of the ordered elements

  • all.perms.flag: 1 if the perms array contains the entire collection of permutations, 0 otherwise. In the first case, the number of rows of perms matrix may be less than the number of requested permutations

  • nperms.act: the number of permutations returned

Examples

Run this code
# NOT RUN {
sub.perm<-getPermutations(10,100)
all.perm<-getPermutations(3,100)
# }

Run the code above in your browser using DataCamp Workspace