Say I have three numbers: 1, 2 and 3 that I want to generate all possible combinations from, but the order in which they occur doesn’t matter. So for this example, using 1 2 3, this is what I want to generate:
11 21 2 3 2 2 31 3 3
The only combination generating function I know would be perms(1:3), but that would create:
3 2 13 1 22 3 12 1 31 2 31 3 2
In my situation the internal order in which the number occurs does not matter, so 1 2 means the same thing to me as 2 1 which should require fewer combinations.
Is there a command to generate sequences like this?
Thanks
Best Answer