From: "Ales Ziberna" <aleszib at gmail.com>
Date: Thu, 8 Dec 2005 15:45:37 +0100
To: "R-help" <r-help at stat.math.ethz.ch>
Subject: [R] Finding all possible partitions of N units into k classes
Dear useRs!
I would like to generate a list of all possible (unique) partitions of N
units into k classes. For example, all possible partitions of 4 units into 2
classes are (I hope I have not missed anyone):
1,1,1,2 (this can be read as {1,2,3},{4})
1,1,2,1
1,2,1,1
2,1,1,1
1,1,2,2
1,2,1,2
1,2,2,1
The partitions 1,1,2,2 and 2,2,1,1 are the same and are therefore not two
unique partitions.
Thank you in advance for any suggestions.
Best,
Ales Ziberna