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 starting from a combination that contain a certain number.

Usage

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

Arguments

n

Vector of any kind, or a numerical scalar.

k

Numeric scalar.

ogte

At least one value greater than or equal to this number.

zerobased

Logical, zero or one based.

Details

When a scalar, argument n should be numeric, otherwise when a vector its length should not be less than k.

When the argument ogte is specified, the combinations will sequentially be incremented from those which contain a certain number, or a certain position from n when specified as a vector.

Value

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

Author(s)

Adrian Dusa

Examples

combnk(5, 2)

combnk(5, 2, ogte = 3)

combnk(letters[1:5], 2)

[Package admisc version 0.35 Index]