combnk {admisc}R Documentation

Generate all combinations of n numbers, taken k at a time

Description

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.

Usage

combnk(n, k, aloe = 0, zerobased = FALSE)

Arguments

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.

Details

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.

Value

A matrix with k rows and choose(n, k) columns.

Author(s)

Adrian Dusa

Examples

combnk(5, 2)

combnk(5, 2, aloe = 3)

[Package admisc version 0.3 Index]