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

combnkR 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)

admisc documentation built on Sept. 12, 2024, 6:27 a.m.

Related to combnk in admisc...