-4
我有兩個載體:如何在R中對兩個向量進行排序?
vector1<- c(0.01,0.02,0.04,0.5,0.9,0.002,0.07,0.008)
vector2<- c(1,0,0,1,0,0,0,0)
vector2
示出了在特定的一組vector 1
每個元素的成員資格。我想排序vecotor1
,但vector 2
也應該排序w.r.t vector 1
。我如何在R中推動它?
預期輸出:
sort(vector1, decreasing=T)
[1] 0.900 0.500 0.070 0.040 0.020 0.010 0.008 0.002
>sorted_vector2:
[1] 0 1 0 0 0 1 0 0
你爲什麼要重新發布了同樣的問題第二次? – josliber
,因爲你的回答錯了! – user2806363