combos

0th

Percentile

Ordered Combinations

All m combinations of the first n integers taken p at a time are computed and return as an p by m matrix. The columns of the matrix are ordered so that adjacent columns differ by only one element. This is just a reordered version of combn in base R, but the ordering is useful for some applications.

Keywords
utilities
Usage
combos(n,p)
Arguments
n

The n in n choose p

p

The p in n choose p

Value

a matrix of dimension p by choose(n,p)

Note

Implementation based on a Pascal algorithm of Limin Xiang and Kazuo Ushijima (2001) translated to ratfor for R. If you have rgl installed you might try demo("combos") for a visual impression of how this works.

References

Limin Xiang and Kazuo Ushijima (2001) "On O(1) Time Algorithms for Combinatorial Generation," Computer Journal, 44(4), 292-302.

Aliases
  • combos
Examples
# NOT RUN {
H <- combos(20,3)
# }
Documentation reproduced from package quantreg, version 5.54, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.