All k possible combinations from n elements
All k possible combinations from n elements.
comb_n(n, k,simplify=TRUE)
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. |
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.
Manos Papadakis and Marios Dimitriadis
R implementation and documentation: Manos Papadakis <papadakm95@gmail.com> and Marios Dimitriadis <kmdimitriadis@gmail.com>.
Nijenhuis A. and Wilf H.S. (1978). Combinatorial Algorithms for Computers and Calculators. Academic Press, NY.
system.time( comb_n(20, 4) ) system.time( combn(20, 4) ) x <- rnorm(5) res<-comb_n(x, 3)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.