Generate a powerset

powerset(x)

Arguments

x

A list or vector of values to generate all possible combinations of

Value

A list with all possible combinations of x

Examples

powerset(x = 1:3)
#> [[1]]
#> [1] 1
#> 
#> [[2]]
#> [1] 2
#> 
#> [[3]]
#> [1] 3
#> 
#> [[4]]
#> [1] 1 2
#> 
#> [[5]]
#> [1] 1 3
#> 
#> [[6]]
#> [1] 2 3
#> 
#> [[7]]
#> [1] 1 2 3
#> 
powerset(x = letters[1:3])
#> [[1]]
#> [1] "a"
#> 
#> [[2]]
#> [1] "b"
#> 
#> [[3]]
#> [1] "c"
#> 
#> [[4]]
#> [1] "a" "b"
#> 
#> [[5]]
#> [1] "a" "c"
#> 
#> [[6]]
#> [1] "b" "c"
#> 
#> [[7]]
#> [1] "a" "b" "c"
#>