combinations | R Documentation |
Returns a matrix containing each possible combination of one entry from vectors of the lengths provided.
combinations(p) powerSetMat(n)
p |
vector of non-negative integers. |
n |
non-negative integer. |
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))
.
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.
Robin Evans
combinations(c(2,3,3)) powerSetMat(3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.