Adrian
Adrian

Reputation: 9793

R: enumerating sequences of permutations

I want to enumerate the distinct sequences of different permutations, and I'm using the function permn. I understand for 2!, I can just use permn(2) and that will enumerate 1, 2 and 2, 1.

> library(combinat)
> permn(2)
[[1]]
[1] 1 2

[[2]]
[1] 2 1

I want to do the same thing for the numbers 7 and 8. So what should I pass into the function so that it will return something like this?

> permn(...)
[[1]]
[1] 7 8

[[2]]
[1] 8 7

Upvotes: 1

Views: 46

Answers (1)

eddi
eddi

Reputation: 49448

permn(c(7,8))
#[[1]]
#[1] 7 8
#
#[[2]]
#[1] 8 7

Upvotes: 2

Related Questions