Rfast (version 1.7.3)

All k possible combinations from n elements: All k possible combinations from n elements

Description

All k possible combinations from n elements.

Usage

comb_n(n, k, trans = FALSE)

Arguments

n
A stirctly (greater than zero) positive integer number.
k
A positive integer number at most equal to n.
trans
A boolean value for returning the matrix transposed.

Value

A matrix with k columns and rows equal to the number of possible unique combinations with k elements.

References

Nijenhuis, A. and Wilf, H.S. (1978). Combinatorial Algorithms for Computers and Calculators. Academic Press, NY.

See Also

nth, colMaxs, colMins, colrange

Examples

Run this code
system.time( comb_n(20, 4) )
system.time( combn(20, 4) )

Run the code above in your browser using DataLab