combinations {rje} | R 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, \ldots, 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 \times \cdots \times 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)
[Package rje version 1.12.1 Index]