Learn R Programming

HapEstXXR (version 0.1-8)

powerset: Generating power set of a set

Description

Generates the power set of a given set of values.

Usage

powerset(x, fileout = NA, only.file = FALSE)

Arguments

x
a vector.
fileout
a character string which contains name of the target file.
only.file
a logical. Only a file is created, if true (default=FALSE).

Value

powerset generates a list of all subsets of x, excluding empty set, if only.file=F.

Details

Suppose you have a set S. The power set is the set off all subsets of S, including empty set and S itself. The number of elements of the power set is 2^(number of elements of S). You can save the powerset in a file, if a filename fileout is specified.

Empty set will be excluded.

Examples

Run this code
ps <- powerset(1:10)
ps

Run the code above in your browser using DataLab