Skip to content
Back to formatted view

Raw Message

Message-ID: <5.1.1.5.2.20021125164905.03f1b848@poptop.llnl.gov>
Date: 2002-11-26T00:54:38Z
From: Pauline Gu
Subject: permutation
In-Reply-To: <x2k7j1tchj.fsf@biostat.ku.dk>

Dear R experts,

Is there any function in R that I can calculate the permutation lists?  I 
would like to know if there is any generic one for finding all the 
permutation of n choose k?

For example:

perms <- list(1:2)
perms <- add.ttt(3:4, perms)
should give me
 > perms
[[1]]
[1] 3 4 1 2

[[2]]
[1] 3 1 4 2

[[3]]
[1] 3 1 2 4

and perms <- add.ttt(5:6, perms)
should give me:
[[1]]
[1] 5 6 3 4 1 2

[[2]]
[1] 5 3 6 4 1 2

[[3]]
[1] 5 3 4 6 1 2

[[4]]
[1] 5 3 4 1 6 2

[[5]]
[1] 5 3 4 1 2 6

[[6]]
[1] 5 6 3 1 4 2

[[7]]
[1] 5 3 6 1 4 2

[[8]]
[1] 5 3 1 6 4 2

[[9]]
[1] 5 3 1 4 6 2

[[10]]
[1] 5 3 1 4 2 6

[[11]]
[1] 5 6 3 1 2 4

[[12]]
[1] 5 3 6 1 2 4

[[13]]
[1] 5 3 1 6 2 4

[[14]]
[1] 5 3 1 2 6 4

[[15]]
[1] 5 3 1 2 4 6


This example is just for those with k=2.  How would I calculate those for 
any k?

Thanks in advance for your help.

Pauline

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._