我知道这个问题与这个问题非常相似:
考虑到我们有这样的数据:
test <- data.frame(A=c("aaabbb",
"aaaabb",
"aaaabb",
"aaaaab",
"bbbaaa",
"bbbbaa"),
B=c("10.00",
"00.04",
"00.04",
"00.00",
"20.00",
"00.06"
))
不过,我需要对平局进行平均,这样我就有了这样的东西:
> test
A B C
1 aaabbb 10.00 1
2 aaaabb 00.04 2.5
3 aaaabb 00.04 2.5
4 aaaaab 00.00 3
5 bbbaaa 20.00 4
6 bbbbaa 00.06 5
编辑:
> dput(qual_orderedadj_ranks)
structure(list(words = structure(c(29L, 7L, 28L, 6L, 19L, 21L,
9L, 11L, 30L, 1L, 8L, 10L, 13L, 12L, 5L, 26L, 27L, 32L, 33L,
3L, 22L, 18L, 16L, 24L, 25L, 31L, 23L, 2L, 17L), .Label = c("average","yellow", "emerald",
"sense","slate", "turcquoise", "green", "orange", "fair", "chestnut", "sand", "good",
"silver", "sense", "sense", "gray", "lousy", "wine", "smalt", "sense", "taupe", "poor",
"blue", "red", "black", "gold", "white", "teal", "terracotta", "purple", "violett",
"olive", "khaki"), class = "factor"), enzo = c(9.57973168019844, 2.68331227860491,
1.85920971038049, 1.28384868054554, 0.885031778228944, 0.740942048756444,
0.415649187810432, 0.0418303446590026, 0.0836608598897025, 0.680367202534345,
1.53377945661345, 1.70660459871111, 39.2413924890553,
239.081124461913, 0, 0, 0, 0, 0, 86.5734538416169, 24.2262630473592,
0.669305983927372, 0.5093534157301, 0.25098462655732, 0.0836608598897025,
0.0418303446590026, 0.276963945905033, 0.839118699701029, 1.00634089909635),
ranks = c(1, 2, 3, 4, 5, 6, 7, 17, 17, 10, 11, 12, 13, 14,
17, 17, 17, 17, 17, 20, 21, 22, 23, 24, 17, 17, 27, 28, 29)), row.names =
c(1L, 2L, 3L, 4L, 6L, 8L, 9L, 28L, 27L, 22L, 21L, 20L, 18L, 16L, 11L,
12L, 13L, 14L, 15L, 17L, 19L, 23L, 24L, 25L, 26L, 29L, 10L, 7L,
5L), .Names = c("words", "enzo", "ranks"), class = "data.frame")