R 函数学习 - rank()
2020-03-29 本文已影响0人
Thinkando
- 简单排序
> a = c(2,1,3,4)
> rank(a)
[1] 2 1 3 4
- 碰到重复,取index 的平均
> a = c(2,1,3,4,2,2)
> rank(a)
[1] 3 1 5 6 3 3
> rank(a,ties.method = 'average')
[1] 3 1 5 6 3 3
- (2+3+4)/3=3
> a = c(2,1,3,4)
> rank(a)
[1] 2 1 3 4
> a = c(2,1,3,4,2,2)
> rank(a)
[1] 3 1 5 6 3 3
> rank(a,ties.method = 'average')
[1] 3 1 5 6 3 3