R:如何按两个百分比维度之一对 prop.table 进行排序?

R: How do I sort a prop.table by one of the two percent dimensions?

如何按显示的较低百分比对其进行排序?

A1 <- round(prop.table(Contigency_Table,margin=2),2)
A1
            1    2    3    4    5    6    7    8    9   10   11   12   13
  -1     0.90 0.30 0.00 0.25 0.80 0.60 0.30 1.00 0.65 0.10 0.50 0.15 0.75
  1      0.10 0.70 1.00 0.75 0.20 0.40 0.70 0.00 0.35 0.90 0.50 0.85 0.25

13对需要配对。它们各自加起来为 100% (1.0)。

我已经尝试了很多东西。

更新

> dput(A1)
structure(c(0.90, 0.10, 0.30, 0.70, 0, 1, 0.25, 0.75, 0.80, 0.20, 0.60, 0.40, 0.30, 0.70, 1, 0, 0.65, 0.35, 0.10, 0.90, 0.50, 0.50, 0.15, 0.85, 0.75, 0.25), class = "table", .Dim = c(2L, 13L), .Dimnames = structure(list(c("-1", "1"), c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13")), .Names = c("", "")))

如果我们想order基于第2行,子集第2行(A1[2,]通过在i上指定行索引),order向量并将其用作列索引以在 j

中重新排序
A2 <- A1[,order(A1[2,])]
A2
#       8    1    5   13    9    6   11    2    7    4   12   10    3
#  -1 1.00 0.90 0.80 0.75 0.65 0.60 0.50 0.30 0.30 0.25 0.15 0.10 0.00
#  1  0.00 0.10 0.20 0.25 0.35 0.40 0.50 0.70 0.70 0.75 0.85 0.90 1.00


colSums(A2)
# 8  1  5 13  9  6 11  2  7  4 12 10  3 
# 1  1  1  1  1  1  1  1  1  1  1  1  1