All k possible combinations from n elements {Rfast}R Documentation

All k possible combinations from n elements

Description

All k possible combinations from n elements.

Usage

comb_n(n, k,simplify=TRUE)

Arguments

n

A positive INTEGER number or a vector with numbers.

k

A positive integer number at most equal to n or at most equal to the length of n, if n is a vector.

simplify

A logical value for return List instead of matrix.

Value

A matrix with k columns and rows equal to the number of possible unique combinations of n with k elements. If simplify is set to TRUE then a list with k values where each value has length equal to the number of possible unique combinations of n with k elements.

Author(s)

Manos Papadakis and Marios Dimitriadis

R implementation and documentation: Manos Papadakis <papadakm95@gmail.com> and Marios Dimitriadis <kmdimitriadis@gmail.com>.

References

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

See Also

nth, colMaxs, colMins, colrange

Examples

comb_n(20, 4)
combn(20, 4)
x <- rnorm(5)
res<-comb_n(x, 3)

[Package Rfast version 2.1.0 Index]