Skip to contents

This function returns all permutations of a given vector.

Usage

permutations(x)

Arguments

x

A vector.

Value

A list of all permutations of x.

References

This function is a modified version of https://stackoverflow.com/a/20199902/15157768.

Examples

RprobitB:::permutations(x = c("a", "b", "c"))
#> [[1]]
#> [1] "a" "b" "c"
#> 
#> [[2]]
#> [1] "a" "c" "b"
#> 
#> [[3]]
#> [1] "b" "a" "c"
#> 
#> [[4]]
#> [1] "b" "c" "a"
#> 
#> [[5]]
#> [1] "c" "a" "b"
#> 
#> [[6]]
#> [1] "c" "b" "a"
#>