This function creates all permutations of a given vector.
References
Modified version of https://stackoverflow.com/a/20199902/15157768.
See also
Other vector helpers:
check_numeric_vector(),
check_probability_vector(),
chunk_vector(),
equidistant_vectors(),
insert_vector_entry(),
map_indices(),
match_numerics(),
split_vector_at(),
subsets(),
vector_occurrence()
Examples
permutations(1:3)
#> [[1]]
#> [1] 1 2 3
#>
#> [[2]]
#> [1] 1 3 2
#>
#> [[3]]
#> [1] 2 1 3
#>
#> [[4]]
#> [1] 2 3 1
#>
#> [[5]]
#> [1] 3 1 2
#>
#> [[6]]
#> [1] 3 2 1
#>
permutations(LETTERS[1:3])
#> [[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"
#>
