2
我有一個很大的R矩陣,我想按一列對所有數據進行排序,但該列需要以奇怪的方式排序(即不按升序或降序排列)。下面是一個例子:按列排序大R矩陣與矢量
test=matrix(data=c("A","B","C","D","E","E","F","F","F",1,2,2,3,4,5,6,6,6),ncol=2)
> test
[,1] [,2]
[1,] "A" "1"
[2,] "B" "2"
[3,] "C" "2"
[4,] "D" "3"
[5,] "E" "4"
[6,] "E" "5"
[7,] "F" "6"
[8,] "F" "6"
[9,] "F" "6"
現在我需要的矩陣通過柱2使用矢量進行排序:
X = C(3,4,5,6,1,2)
我知道我需要使用順序函數,因爲我想保持來自其他列的數據的正確順序。
有多大「大」? – Roland