<p>Hi,</p>

<p>I'm trying do some permutation testing on microarray data in R and the sample labels look like this:</p>

<pre><code>labels &lt;- c("case_1", "case_2", "case_3", "case_4", "case_5",
            "control_1", "control_2", "control_3", "control_4", "control_5")
</code></pre>

<p>To permute them I realize I could just repeatedly use "sample(labels)" to do random permutations, but I'd like to look ALL possible permutations.</p>

<p>I think there should be ((10 choose 5) / 2) = 126 possibilities.</p>

<p>Does anyone know if there's an easy way to generate these though?</p>

<p>Thanks!</p>

Using the standard R libaries, you can do it with the combn() function

    > a = c(1,2,3,4)
    > combn(a,3)
         [,1] [,2] [,3] [,4]
    [1,]    1    1    1    2
    [2,]    2    2    3    3
    [3,]    3    4    4    4

Your combinations are in the columns.
