combnk {admisc} | R Documentation |
A fast function to generate all possible combinations of n numbers, taken k at a time, starting from the first k numbers or from a combination that contain a certain number.
combnk(n, k, aloe = 0, zerobased = FALSE)
n |
A vector of mode numeric, character or factor. |
k |
Character string or a vector of character strings for recoding specifications. |
aloe |
At least one value equal to this number. |
zerobased |
Logical, zero or one based. |
This function differs from function combn
in package utils
,
covering only numerical vectors and therefore a lot faster.
When the argument aloe
is specified, the combinations will sequentially
be incremented from those which contain that number.
A matrix with k
rows and choose(n, k)
columns.
Adrian Dusa
combnk(5, 2) combnk(5, 2, aloe = 3)