combinations: Combinations of Integers

combinationsR Documentation

Combinations of Integers

Description

Returns a matrix containing each possible combination of one entry from vectors of the lengths provided.

Usage

combinations(p)
powerSetMat(n)

Arguments

p

vector of non-negative integers.

n

non-negative integer.

Details

Returns a matrix, each row being one possible combination of integers from the vectors (0, 1,..., p_i - 1), for i between 1 and length(p).

Based on bincombinations from package e1071, which provides the binary case.

powerSetMat is just a wrapper for combinations(rep(2, n)).

Value

A matrix with number of columns equal to the length of p, and number of rows equal to p_1 * ... * p_k, each row corresponding to a different combination. Ordering is reverse-lexographic.

Author(s)

Robin Evans

Examples


combinations(c(2,3,3))

powerSetMat(3)


rje documentation built on Nov. 12, 2022, 9:06 a.m.