combinations in the gtools package can be helpfull here, best, ingmar > From: "Ales Ziberna" <[EMAIL PROTECTED]> > Date: Thu, 8 Dec 2005 15:45:37 +0100 > To: "R-help" <r-help@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 > > ______________________________________________ > 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 >
______________________________________________ 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