[R] Permutations
Jordi Altirriba Gutiérrez
altirriba at hotmail.com
Wed Jul 14 18:16:34 CEST 2004
Dear R users,
First of all, thanks to Rolf, Brad, Robin, Erich, Fernando and Adaikalavan
for your time and suggestions.
Ive been testing some algorithms (sorry for the delay, Im very slow, and
Im a completely beginner in Rs world).
First, the Robin algorithm.
I think that there is a problem because Ive done 200 permutations and
Ive found that these permutations are the same:
52 and 91, 99 and 110, 121 and 122, 51 and 141, 130 and 134.
Thanks again,
Jordi Altirriba
Hospital Clinic - Barcelona - Spain
>x <- c(1,2,3,4,5,6,7,8,9,10,11,12)
>dim(x) <- c(3,4) a<-matrix(1,200,12)
>for (i in 1:200)
+ {
+ jj <- t(apply(x,1,sample))
+ a[i,]<-as.vector(jj)
+ }
>a
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
[1,] 7 2 3 1 11 6 4 8 9 10 5 12
[2,] 1 2 9 7 11 6 4 8 12 10 5 3
[3,] 7 2 9 1 11 3 4 5 6 10 8 12
[4,] 10 8 6 4 5 12 7 2 9 1 11 3
[5,] 10 2 12 1 11 9 7 8 6 4 5 3
[6,] 7 8 6 1 5 9 4 11 12 10 2 3
[7,] 1 5 12 7 2 6 4 8 9 10 11 3
[8,] 1 5 9 10 8 6 4 2 3 7 11 12
[9,] 1 11 6 7 2 12 4 5 9 10 8 3
[10,] 4 5 12 10 11 9 1 8 6 7 2 3
[11,] 1 11 9 7 5 6 4 8 12 10 2 3
[12,] 1 8 3 4 2 12 10 5 9 7 11 6
[13,] 1 2 3 7 11 6 10 5 12 4 8 9
[14,] 4 8 3 10 5 12 7 2 9 1 11 6
[15,] 10 2 3 4 8 6 7 11 9 1 5 12
[16,] 4 8 9 10 2 12 7 5 6 1 11 3
[17,] 1 2 6 10 5 3 7 8 12 4 11 9
[18,] 10 2 9 4 11 12 1 5 6 7 8 3
[19,] 4 8 6 7 11 12 1 2 9 10 5 3
[20,] 1 8 12 7 2 3 10 11 6 4 5 9
[21,] 10 2 12 1 5 9 7 11 6 4 8 3
[22,] 4 11 12 1 2 3 10 8 6 7 5 9
[23,] 1 11 3 7 2 6 10 5 9 4 8 12
[24,] 7 2 9 10 5 12 1 11 3 4 8 6
[25,] 7 8 9 1 2 6 4 5 3 10 11 12
[26,] 4 5 12 10 2 3 7 11 6 1 8 9
[27,] 4 5 9 1 11 3 7 8 12 10 2 6
[28,] 1 5 6 4 11 3 7 8 9 10 2 12
[29,] 4 5 6 1 11 9 10 2 12 7 8 3
[30,] 4 11 3 7 8 12 10 5 6 1 2 9
[31,] 10 2 3 1 11 6 7 8 9 4 5 12
[32,] 10 2 3 7 8 9 1 11 6 4 5 12
[33,] 7 11 6 1 8 9 4 5 12 10 2 3
[34,] 7 5 12 1 8 6 4 11 3 10 2 9
[35,] 1 2 3 4 8 6 7 5 9 10 11 12
[36,] 7 8 3 1 11 9 10 2 12 4 5 6
[37,] 10 2 6 1 11 12 7 5 3 4 8 9
[38,] 1 5 9 4 11 12 7 8 3 10 2 6
[39,] 1 2 12 7 5 9 10 8 3 4 11 6
[40,] 1 8 3 10 2 12 7 11 6 4 5 9
[41,] 1 2 9 4 8 3 10 11 12 7 5 6
[42,] 4 5 6 1 2 9 10 8 3 7 11 12
[43,] 1 2 6 7 11 12 10 5 9 4 8 3
[44,] 1 2 9 10 11 12 4 8 6 7 5 3
[45,] 10 5 9 7 11 6 4 2 3 1 8 12
[46,] 1 2 3 4 11 6 7 5 9 10 8 12
[47,] 4 2 6 1 8 3 10 5 12 7 11 9
[48,] 4 8 9 7 2 3 1 5 12 10 11 6
[49,] 10 8 12 1 2 9 4 11 3 7 5 6
[50,] 10 8 6 1 2 3 7 5 12 4 11 9
[51,] 7 2 12 10 11 6 4 8 3 1 5 9
[52,] 4 5 6 1 2 12 10 11 9 7 8 3
[53,] 1 2 3 7 5 6 4 8 9 10 11 12
[54,] 10 5 3 7 11 9 1 8 6 4 2 12
[55,] 7 11 12 4 2 3 10 8 6 1 5 9
[56,] 1 5 9 4 11 12 10 8 3 7 2 6
[57,] 4 5 9 7 11 3 10 2 6 1 8 12
[58,] 10 11 3 4 5 6 1 8 12 7 2 9
[59,] 4 8 9 10 5 6 7 2 3 1 11 12
[60,] 4 2 12 1 8 6 10 5 9 7 11 3
[61,] 4 8 6 7 11 9 10 5 12 1 2 3
[62,] 7 8 3 10 5 6 1 11 12 4 2 9
[63,] 10 5 3 7 8 6 1 2 9 4 11 12
[64,] 10 2 9 4 11 12 1 5 3 7 8 6
[65,] 1 11 6 4 8 12 7 2 3 10 5 9
[66,] 1 5 3 7 11 9 4 2 12 10 8 6
[67,] 4 2 6 7 5 12 10 8 9 1 11 3
[68,] 4 11 12 10 2 3 7 8 6 1 5 9
[69,] 4 5 6 10 2 3 7 8 9 1 11 12
[70,] 1 11 12 10 2 6 4 5 3 7 8 9
[71,] 10 5 6 7 8 12 4 2 9 1 11 3
[72,] 10 8 12 1 11 9 7 5 3 4 2 6
[73,] 10 8 3 7 11 9 4 5 12 1 2 6
[74,] 7 2 12 1 5 6 4 8 9 10 11 3
[75,] 7 2 12 10 8 9 1 11 6 4 5 3
[76,] 7 2 3 1 5 9 4 8 12 10 11 6
[77,] 1 11 3 10 5 6 7 2 9 4 8 12
[78,] 7 2 6 10 11 12 4 8 9 1 5 3
[79,] 10 8 6 7 5 3 1 2 9 4 11 12
[80,] 10 11 3 7 2 12 4 8 6 1 5 9
[81,] 10 5 6 1 8 3 4 11 9 7 2 12
[82,] 1 11 3 7 5 12 10 2 6 4 8 9
[83,] 4 11 9 10 5 12 7 2 6 1 8 3
[84,] 1 11 12 7 8 3 4 2 6 10 5 9
[85,] 10 2 9 7 5 6 1 11 12 4 8 3
[86,] 7 11 9 4 5 6 10 2 12 1 8 3
[87,] 4 5 12 7 2 3 10 11 6 1 8 9
[88,] 1 2 12 7 5 3 10 8 6 4 11 9
[89,] 1 8 12 7 11 9 10 2 6 4 5 3
[90,] 4 5 3 10 11 9 7 2 6 1 8 12
[91,] 4 5 6 1 2 12 10 11 9 7 8 3
[92,] 10 11 9 7 5 12 1 2 6 4 8 3
[93,] 4 2 3 7 8 6 1 11 12 10 5 9
[94,] 4 5 3 10 2 12 7 8 9 1 11 6
[95,] 4 8 3 10 11 9 1 2 6 7 5 12
[96,] 7 5 12 10 11 3 1 8 9 4 2 6
[97,] 4 2 3 1 8 6 7 11 9 10 5 12
[98,] 4 11 9 7 5 12 10 8 6 1 2 3
[99,] 1 11 12 4 5 6 7 8 3 10 2 9
[100,] 1 8 3 7 5 6 10 2 12 4 11 9
[101,] 7 11 6 4 8 3 1 2 12 10 5 9
[102,] 7 11 12 1 2 3 10 8 6 4 5 9
[103,] 4 5 12 1 2 9 7 8 3 10 11 6
[104,] 10 11 12 4 8 3 7 5 9 1 2 6
[105,] 10 5 9 1 2 3 4 8 6 7 11 12
[106,] 10 11 9 1 2 12 7 8 3 4 5 6
[107,] 10 11 3 4 8 9 7 5 12 1 2 6
[108,] 7 2 6 1 11 9 4 5 12 10 8 3
[109,] 1 8 6 7 2 12 10 5 3 4 11 9
[110,] 1 11 12 4 5 6 7 8 3 10 2 9
[111,] 7 8 6 1 5 3 10 2 12 4 11 9
[112,] 4 8 3 7 5 6 1 2 9 10 11 12
[113,] 1 2 9 4 11 6 7 5 3 10 8 12
[114,] 4 11 9 1 8 6 7 2 3 10 5 12
[115,] 10 8 3 4 11 12 7 2 9 1 5 6
[116,] 7 11 12 1 2 3 4 8 9 10 5 6
[117,] 1 5 3 10 11 12 7 8 9 4 2 6
[118,] 1 11 6 4 2 9 10 5 12 7 8 3
[119,] 10 2 3 1 5 9 4 8 12 7 11 6
[120,] 1 2 3 4 11 12 7 8 9 10 5 6
[121,] 7 8 3 4 5 12 10 2 6 1 11 9
[122,] 7 8 3 4 5 12 10 2 6 1 11 9
[123,] 4 5 3 10 11 9 7 8 6 1 2 12
[124,] 4 5 6 7 11 9 1 8 12 10 2 3
[125,] 10 8 6 1 11 9 4 2 12 7 5 3
[126,] 10 8 12 4 11 9 7 2 6 1 5 3
[127,] 7 8 12 1 11 6 10 5 9 4 2 3
[128,] 1 8 12 10 11 3 7 5 9 4 2 6
[129,] 7 8 3 10 2 6 1 11 9 4 5 12
[130,] 7 11 9 1 2 6 10 8 3 4 5 12
[131,] 10 2 3 4 11 9 1 5 6 7 8 12
[132,] 4 11 3 1 5 9 10 2 6 7 8 12
[133,] 10 2 12 7 8 3 4 5 6 1 11 9
[134,] 7 11 9 1 2 6 10 8 3 4 5 12
[135,] 7 8 3 4 11 6 10 2 9 1 5 12
[136,] 10 8 9 7 11 12 1 2 6 4 5 3
[137,] 10 8 12 4 5 3 1 2 9 7 11 6
[138,] 1 2 6 10 8 12 7 11 9 4 5 3
[139,] 4 5 3 7 11 9 1 2 12 10 8 6
[140,] 4 5 12 7 8 6 10 11 3 1 2 9
[141,] 7 2 12 10 11 6 4 8 3 1 5 9
[142,] 10 11 12 7 2 6 1 5 3 4 8 9
[143,] 7 2 3 10 11 6 1 8 9 4 5 12
[144,] 1 2 9 10 5 12 4 8 3 7 11 6
[145,] 1 11 6 4 8 9 7 5 12 10 2 3
[146,] 4 5 3 10 2 6 1 11 9 7 8 12
[147,] 7 11 9 1 2 3 10 8 12 4 5 6
[148,] 4 2 3 1 5 12 7 8 6 10 11 9
[149,] 10 11 12 4 8 3 1 2 9 7 5 6
[150,] 4 8 3 10 5 6 1 11 9 7 2 12
[151,] 1 8 6 10 5 9 4 11 3 7 2 12
[152,] 4 8 6 7 11 12 10 5 3 1 2 9
[153,] 7 2 3 10 5 6 4 11 9 1 8 12
[154,] 10 5 12 1 8 9 7 2 3 4 11 6
[155,] 1 8 6 4 2 9 10 5 3 7 11 12
[156,] 10 2 3 7 5 9 4 11 12 1 8 6
[157,] 10 5 3 1 2 6 7 8 9 4 11 12
[158,] 7 11 12 4 5 9 10 8 3 1 2 6
[159,] 7 5 3 1 8 12 10 2 6 4 11 9
[160,] 7 2 6 4 11 3 1 5 12 10 8 9
[161,] 7 5 3 1 2 12 4 8 9 10 11 6
[162,] 7 8 12 1 5 6 10 11 9 4 2 3
[163,] 10 11 9 4 8 6 1 2 3 7 5 12
[164,] 7 11 6 1 5 9 4 2 12 10 8 3
[165,] 4 11 9 10 8 3 7 2 12 1 5 6
[166,] 4 2 6 10 8 9 7 11 12 1 5 3
[167,] 7 5 3 10 2 12 4 8 6 1 11 9
[168,] 1 8 12 7 2 3 4 5 9 10 11 6
[169,] 7 8 12 1 5 6 4 2 3 10 11 9
[170,] 4 5 3 7 8 9 1 2 12 10 11 6
[171,] 7 11 9 1 8 6 4 2 12 10 5 3
[172,] 10 8 3 1 2 9 4 11 12 7 5 6
[173,] 10 5 12 7 8 9 4 11 3 1 2 6
[174,] 10 11 6 7 5 3 4 8 12 1 2 9
[175,] 7 11 12 1 2 3 10 8 9 4 5 6
[176,] 1 11 12 7 2 3 4 8 9 10 5 6
[177,] 10 11 12 4 5 3 7 8 6 1 2 9
[178,] 10 5 3 7 2 6 4 8 12 1 11 9
[179,] 1 5 6 7 2 9 10 11 3 4 8 12
[180,] 1 11 12 10 5 6 4 2 3 7 8 9
[181,] 7 2 12 4 11 9 1 5 6 10 8 3
[182,] 10 11 12 1 5 3 7 8 9 4 2 6
[183,] 4 8 3 1 11 9 7 2 6 10 5 12
[184,] 4 8 9 7 2 3 10 5 6 1 11 12
[185,] 10 11 9 1 5 6 7 2 12 4 8 3
[186,] 10 5 12 4 8 9 7 2 6 1 11 3
[187,] 4 2 3 1 8 6 7 5 12 10 11 9
[188,] 10 2 9 4 11 12 1 8 3 7 5 6
[189,] 10 2 12 7 11 3 4 5 9 1 8 6
[190,] 4 5 6 7 8 3 10 11 9 1 2 12
[191,] 10 5 9 1 2 3 7 11 12 4 8 6
[192,] 4 11 9 7 2 6 10 5 3 1 8 12
[193,] 10 11 12 1 2 6 4 5 9 7 8 3
[194,] 10 2 3 4 11 12 7 5 6 1 8 9
[195,] 4 2 6 7 8 9 1 11 3 10 5 12
[196,] 10 2 12 4 8 6 7 5 3 1 11 9
[197,] 7 5 12 4 11 9 1 2 3 10 8 6
[198,] 10 5 6 1 11 3 7 2 9 4 8 12
[199,] 1 2 9 7 11 3 4 8 6 10 5 12
[200,] 4 8 3 7 11 12 1 2 6 10 5 9
>From: Robin Hankin <rksh at soc.soton.ac.uk>
>To: Jordi Altirriba Gutiérrez <altirriba at hotmail.com>
>CC: r-help at stat.math.ethz.ch
>Subject: Re: [R] (no subject) (was: Permutations)
>Date: Wed, 14 Jul 2004 09:11:48 +0100
>
>Jordi
>
>try this
>
>
>R> x <- c(1,2,3, 10,11,12, 41,42,43, 81,82,83)
>R> dim(x) <- c(3,4)
>R> x
> [,1] [,2] [,3] [,4]
>[1,] 1 10 41 81
>[2,] 2 11 42 82
>[3,] 3 12 43 83
>R> jj <- t(apply(x,1,sample))
>R> jj
> [,1] [,2] [,3] [,4]
>[1,] 1 41 10 81
>[2,] 2 11 82 42
>[3,] 12 3 43 83
>R> as.vector(jj)
>R>
> [1] 1 2 12 41 11 3 10 82 43 81 42 83
>
>
>
>
>and I think that does what you want...
>
>We take the vector, rearrange it into a matrix with three rows, then sample
>*within* the rows,
>then rearrange into a vector again.
>
>There will be one forbidden permutation, namely the identity (which may or
>may not be
>desirable).
>
>This method doesn't allow "intra block" permutations.
>
>best
>
>rksh
>
>
>
>> Dear R users,
>> First of all, thanks for the incredibly fast answers and help of Rolf,
>>Marc and Robert.
>> Yes, I noticed that it was a lot of permutacions, but my intention was
>>to make this process automatic and take only 5.000 - 10.000 permutations.
>>Therefore, I wanted only to take that "interesting permutations" with
>>"some information" [inter-block permutations].
>> The reason why I'm interested in these permutations is because I'm using
>>some packages of Bioconductor to analyse my data from some microarrays and
>>I thought that perhaps could be interesting to see what happens when I
>>permute my data and I compare it against the not permuted data.
>> Thanks again for your time and suggestions.
>>
>>Jordi Altirriba
>>Ph. D. Student
>>
>>Hospital Clinic-Barcelona-Spain
>>
>>______________________________________________
>>R-help at stat.math.ethz.ch mailing list
>>https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>>PLEASE do read the posting guide!
>>http://www.R-project.org/posting-guide.html
>
>
>--
>Robin Hankin
>Uncertainty Analyst
>Southampton Oceanography Centre
>SO14 3ZH
>tel +44(0)23-8059-7743
>initialDOTsurname at soc.soton.ac.uk (edit in obvious way; spam precaution)
More information about the R-help
mailing list