I want to generate all possible permutations of the vector
c(1,2,2,3,3)
in R. I used the following code:
library(combinat)
permn(c(1,2,2,3,3))
However, this function generates 5!=120 permutations, because it distinguishes the two 2 and the two 3. It should generate 5!/(2!*2!)=30 combinations.
This problem is solved using
unique(permn(c(1,2,2,3,3)))
However, I would like a function that gives the output of
unique(permn(c(1,2,2,3,3)))
directly, in a single function, not computing first all possible permutations via
permn(c(1,2,2,3,3))