[R] Finding all possible partitions of N units into k classes

From: Ales Ziberna <aleszib_at_gmail.com>
Date: Fri 09 Dec 2005 - 01:45:37 EST


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



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Dec 09 02:11:01 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:41:34 EST