powerSet {rje} | R Documentation |
Produces the power set of a vector.
powerSet(x, m, rev = FALSE)
x |
vector of elements (the set). |
m |
maximum cardinality of subsets |
rev |
logical indicating whether to reverse the order of subsets. |
Creates a list containing every subset of the elements of the vector
x
.
A list of vectors of the same type as x
.
With rev = FALSE
(the defualt) the list is ordered such that all
subsets containing the last element of x
come after those which do
not, and so on.
Robin Evans
powerSet(1:3) powerSet(letters[3:5], rev=TRUE) powerSet(1:5, m=2)