Learn R Programming

rje (version 1.4)

powerSet: Power Set

Description

Produces the power set of a vector.

Usage

powerSet(x, rev = FALSE)

Arguments

x
vector of elements (the set).
rev
logical indicating whether to reverse the order of subsets.

Value

  • 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.

Details

Creates a list containing every subset of the elements of the vector x.

See Also

powerSetMat.

Examples

Run this code
powerSet(1:3)
powerSet(letters[3:5], rev=TRUE)

Run the code above in your browser using DataLab