From: Ted Harding <Ted.Harding_at_nessie.mcc.ac.uk>

Date: Fri 13 Oct 2006 - 16:40:24 GMT

*[[9]]
*

*[[10]]
*

*[[11]]
*

*[[12]]
*

*[[13]]
*

*[[14]]
*

*[[15]]
*

*[[16]]
*

*[[17]]
*

*[[18]]
*

*[[19]]
*

*[[20]]
*

*[[21]]
*

*[[22]]
*

*[[23]]
*

*[[24]]
*

*[[25]]
*

*[[26]]
*

*[[27]]
*

*[[28]]
*

*[[29]]
*

*[[30]]
*

[1] C B B A A

E-Mail: (Ted Harding) <Ted.Harding@nessie.mcc.ac.uk> Fax-to-email: +44 (0)870 094 0861

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sat Oct 14 04:15:30 2006

Date: Fri 13 Oct 2006 - 16:40:24 GMT

On 13-Oct-06 Robin Hankin wrote:

> Hi > > How do I generate all ways of ordering sets of indistinguishable > items? > > suppose I have two A's, two B's and a C. > > Then I want > > AABBC > AABCB > AACBC ---->> I think you mean AACBB here! > ABABC > . . .snip... > BBAAC > . . .snip... > CBBAA > > [there are 5!/(2!*2!) = 30 arrangements. Note AABBC != BBAAC] > > How do I do this?

Meanwhile, a problem of the order of the one you describe above can be solved quite slickly:

X<-c("A","A","B","B","C")

library(combinat)

##[result below stripped of " quotes for clarity]
unique(array(permn(X)))

*[[1]]
*

[1] A A B B C

[[2]]

[1] A A B C B

[[3]]

[1] A A C B B

[[4]]

[1] A C A B B

[[5]]

[1] C A A B B

[[6]]

[1] A B A B C

[[7]]

[1] A B A C B

[[8]]

[1] A B C A B

[1] A C B A B

[1] C A B A B

[1] C B A A B

[1] B C A A B

[1] B A C A B

[1] B A A C B

[1] B A A B C

[1] B A B A C

[1] B A B C A

[1] B A C B A

[1] B C A B A

[1] C B A B A

[1] C A B B A

[1] A C B B A

[1] A B C B A

[1] A B B C A

[1] A B B A C

[1] B B A A C

[1] B B A C A

[1] B B C A A

[1] B C B A A

[1] C B B A A

However, the above simple function will quickly get short of breath if the total number of items gets much above, say 10.

Hoping this helps!

Ted.

E-Mail: (Ted Harding) <Ted.Harding@nessie.mcc.ac.uk> Fax-to-email: +44 (0)870 094 0861

Date: 13-Oct-06 Time: 17:40:20 ------------------------------ XFMail ------------------------------ ______________________________________________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 and provide commented, minimal, self-contained, reproducible code. Received on Sat Oct 14 04:15:30 2006

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.1.8, at Fri 13 Oct 2006 - 19:30:09 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*