[R] combinatorics

2006-10-13 Thread Robin Hankin
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 ABABC . . .snip... BBAAC . . .snip... CBBAA [there are 5!/(2!*2!) = 30 arrangements. Note AABBC != BBAAC] How do I do this? -- Robin Hankin

Re: [R] combinatorics

2006-10-13 Thread Christos Hatzis
quot;ACBAB" "BACAB" "ABCAB" "CAABB" "ACABB" "AACBB" "BAACB" [23] "ABACB" "AABCB" "BBAAC" "BABAC" "ABBAC" "BAABC" "ABABC" "AABBC" > length(res) [1] 30

Re: [R] combinatorics

2006-10-13 Thread Robin Hankin
"BAACB" > [23] "ABACB" "AABCB" "BBAAC" "BABAC" "ABBAC" "BAABC" "ABABC" "AABBC" >> length(res) > [1] 30 > > -Christos > > Christos Hatzis, Ph.D. > Nuvera Biosciences, Inc. > 400

Re: [R] combinatorics

2006-10-13 Thread jim holtman
Use 'permutations' in 'gtools' x <- permutations(5,5) y <- c('a','a','b','b','c')[x] dim(y) <- dim(x) unique(y) On 10/13/06, Robin Hankin <[EMAIL PROTECTED]> 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. > >

Re: [R] combinatorics

2006-10-13 Thread Ted Harding
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 >

Re: [R] combinatorics

2006-10-13 Thread Charles C. Berry
On Fri, 13 Oct 2006, 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 > ABABC > . . .snip... > BBAAC > . . .snip... > CBBAA > > [there are 5!/(2!*2!) = 30 arr

Re: [R] combinatorics

2006-10-13 Thread hadley wickham
> I've tried to think of an efficient and economical (and therefore > clever) way of doing this for larger problems; but that will have > to wait for another day! The ruby permutations library (http://permutation.rubyforge.org/doc/index.html) references The Algorithm Design Manual, Steven S. Skie

Re: [R] combinatorics

2006-10-13 Thread Duncan Temple Lang
"ACBBA" >>"BACBA" "ABCBA" >>"BBACA" "BABCA" >>[12] "ABBCA" "CBAAB" "BCAAB" "CABAB" "ACBAB" "BACAB" "ABCAB" >>"CAABB" "ACABB" >>"AACBB&

Re: [R] combinatorics

2006-10-15 Thread Jens Scheidtmann
Robin Hankin <[EMAIL PROTECTED]> writes: > 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 > ABABC > . . .snip... > BBAAC > . . .snip... > CBBAA > > [there are 5!/(2!*2!) = 30 arr

[R] combinatorics again

2006-03-06 Thread Robin Hankin
Hi I want to enumerate all vectors of length "J", whose elements are integers in the range 1 to S, without regard to ordering. With J=S=3, the combinations are as follows: [,1] [,2] [,3] [1,]111 [2,]112 [3,]113 [4,]122 [5,]1

Re: [R] combinatorics again

2006-03-06 Thread Jacques VESLOT
> library(gtools) > combinations(5,3) [,1] [,2] [,3] [1,]123 [2,]124 [3,]125 [4,]134 [5,]135 [6,]145 [7,]234 [8,]235 [9,]245 [10,]345 Robin Hankin a écrit : >H

Re: [R] combinatorics again

2006-03-06 Thread Robin Hankin
Thank you Jacques but your solution misses (eg) c(1,1,2) which I need. best wishes Robin On 6 Mar 2006, at 09:17, Jacques VESLOT wrote: > > library(gtools) > > combinations(5,3) > [,1] [,2] [,3] > [1,]123 > [2,]124 > [3,]125 > [4,]134 > [

Re: [R] combinatorics again

2006-03-06 Thread Uwe Ligges
Robin Hankin wrote: > Thank you Jacques > > but your solution misses (eg) c(1,1,2) which I need. See ?combinations which should point you to combinations(5,3, repeats.allowed=TRUE) Best, Uwe > best wishes > > Robin > > > > On 6 Mar 2006, at 09:17, Jacques VESLOT wrote: > > >>>library

Re: [R] combinatorics again

2006-03-06 Thread Jacques VESLOT
combinations(5,3,rep=T) Robin Hankin a écrit : > Thank you Jacques > > but your solution misses (eg) c(1,1,2) which I need. > > best wishes > > Robin > > > > On 6 Mar 2006, at 09:17, Jacques VESLOT wrote: > >> > library(gtools) >> > combinations(5,3) >> [,1] [,2] [,3] >> [1,]123

Re: [R] combinatorics again

2006-03-06 Thread Robin Hankin
Patrick, Uwe thanks! [both your solutions were conceptually identical, except for one was "ascending" and one was "descending"] very best wishes Robin On 6 Mar 2006, at 09:36, Uwe Ligges wrote: > Robin Hankin wrote: > >> Thank you Jacques >> >> but your solution misses (eg) c(1,1,2) which