作者Nohporelleb ()
站內Statistics
標題[程式] Permutation in R
時間Mon Oct 25 15:21:57 2010
[軟體程式類別]:
R
[程式問題]:
Permutation for a 18*500 matrix
1. 針對Columns內的elements
2. 針對rows內的elements
3. Columns跟rows都做permutation
[軟體熟悉度]:
新手(不到1個月)
[問題敘述]:
R code for permutation
[程式範例]:
-----------------------------------------------------------------------------
請高手指導了,謝謝!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.218.93
1F:推 Cayley:可以用sample(1:N)會隨機output 1:N的一個permutation @@? 10/26 00:46
2F:推 chien533:去安裝gregmisc這個package,裡面有premutation的語法 10/26 08:39
3F:推 garrrick:permute columns : "aa[ order( sample(1:500) ), ]" 10/29 00:22
4F:→ garrrick:permute rows 也是類似的方式 10/29 00:23
5F:推 garrrick:剛剛弄錯了...應該是 "aa[sample(sample(1:500)),]" 10/29 00:40
6F:→ garrrick:不用 order 10/29 00:40
7F:推 garrrick:I was wrong again, it shoud be " aa[sample(1:500),] " 10/29 11:38