Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在排名上打破平局,但在R中不跳_R - Fatal编程技术网

在排名上打破平局,但在R中不跳

在排名上打破平局,但在R中不跳,r,R,我有一个简单的矩阵,并希望有每个条目的排名 [,1] [,2] [1,] 5 8 [2,] 8 5 当我将rank()与ties.method=min一起使用时,它在tie之后有一个跳转: rankMatrix[] <- rank(-Matrix, ties.method="min") 我的问题是,我不想在平局后排名上升,即: [,1] [,2] [1,] 2 1 [2,] 1 2 有没有办法达到这种排名 提前多谢 我们可以使用de

我有一个简单的矩阵,并希望有每个条目的排名

     [,1] [,2]
[1,]  5    8
[2,]  8    5
当我将rank()与ties.method=min一起使用时,它在tie之后有一个跳转:

rankMatrix[] <- rank(-Matrix, ties.method="min")
我的问题是,我不想在平局后排名上升,即:

     [,1] [,2]
[1,]  2    1
[2,]  1    2
有没有办法达到这种排名


提前多谢

我们可以使用
densite\u-rank

library(dplyr)
m1[] <- dense_rank(-m1)
m1
#      [,1] [,2]
#[1,]    2    1
#[2,]    1    2
库(dplyr)
m1[]
library(dplyr)
m1[] <- dense_rank(-m1)
m1
#      [,1] [,2]
#[1,]    2    1
#[2,]    1    2