- 简单排序
> 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
本文标题:R 函数学习 - rank()
本文链接:https://www.haomeiwen.com/subject/uztuuhtx.html
网友评论