Back

For getting all the permutations, refer to the following code:

> library(combinat)> permn(letters[1:3])[[1]][1] "a" "b" "c"[[2]][1] "a" "c" "b"[[3]][1] "c" "a" "b"[[4]][1] "c" "b" "a"[[5]][1] "b" "c" "a"[[6]][1] "b" "a" "c"

> library(combinat)

> permn(letters[1:3])

[[1]]

[1] "a" "b" "c"

[[2]]

[1] "a" "c" "b"

[[3]]

[1] "c" "a" "b"

[[4]]

[1] "c" "b" "a"

[[5]]

[1] "b" "c" "a"

[[6]]

[1] "b" "a" "c"

Learn R programming from scratch, if you are a beginner in R.

30.9k questions

32.9k answers

500 comments

665 users