yeng
[quote]
scores=c(4,3,4,5,2,3,4,5,4,4,5,5,4,5,4,4,3,4,2,4,5,5,4,4)
person=c(1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3)
boxplot(scores~person)
kruskal.test(scores~person)
(s=rank(scores))
oneway.test (s~person)
[/quote]
其中(s=rank(scores))出现小数,是因为scores的数据有重复吗?点样去解析啊?
yihui
“结”就是tie,有不同的处理方法,参考帮助。
rank(x, na.last = TRUE,
ties.method = c("average", "first", "random", "max", "min"))
> scores=c(4,3,4,5,2,3,4,5,4,4,5,5,4,5,4,4,3,4,2,4,5,5,4,4)
> rank(scores, ties='a')
[1] 11.5 4.0 11.5 21.0 1.5 4.0 11.5 21.0 11.5 11.5 21.0 21.0 11.5 21.0 11.5
[16] 11.5 4.0 11.5 1.5 11.5 21.0 21.0 11.5 11.5
> rank(scores, ties='f')
[1] 6 3 7 18 1 4 8 19 9 10 20 21 11 22 12 13 5 14 2 15 23 24 16 17
> rank(scores, ties='r')
[1] 15 3 14 23 2 5 13 21 10 11 19 22 7 20 17 12 4 8 1 6 18 24 16 9
> rank(scores, ties='max')
[1] 17 5 17 24 2 5 17 24 17 17 24 24 17 24 17 17 5 17 2 17 24 24 17 17
> rank(scores, ties='min')
[1] 6 3 6 18 1 3 6 18 6 6 18 18 6 18 6 6 3 6 1 6 18 18 6 6