Learn R Programming

RcppAlgos (version 2.9.3)

comboRank: Rank Combinations and Permutations

Description

  • Generate the rank (lexicographically) of combinations/permutations. These functions are the complement to comboSample and permuteSample. See the examples below.

  • GMP support allows for exploration of combinations/permutations of vectors with many elements.

Usage

comboRank(..., v, repetition = FALSE, freqs = NULL)
permuteRank(..., v, repetition = FALSE, freqs = NULL)

Value

A vector of class integer, numeric, or bigz determined by the total number of combinations/permutations

Arguments

...

vectors or matrices to be ranked.

v

Source vector. If v is a positive integer, it will be converted to the sequence 1:v. If v is a negative integer, it will be converted to the sequence v:-1. All atomic types are supported (See is.atomic).

repetition

Logical value indicating whether combinations/permutations should be with or without repetition. The default is FALSE.

freqs

A vector of frequencies used for producing all combinations/permutations of a multiset of v. Each element of freqs represents how many times each element of the source vector, v, is repeated. It is analogous to the times argument in rep. The default value is NULL.

Author

Joseph Wood

Details

These algorithms rely on efficiently ranking the \(n^{th}\) lexicographical combination/permutation.

References

Lexicographical order ranking/unranking

See Also

comboSample, permuteSample

Examples

Run this code
mySamp = comboSample(30, 8, TRUE, n = 5, seed = 10, namedSample = TRUE)
myRank = comboRank(mySamp, v = 30, repetition = TRUE)
all.equal(as.integer(rownames(mySamp)), myRank)

Run the code above in your browser using DataLab