[英]apply which.max to second, third, etc. highest value
I have a vector: 我有一个矢量:
x<-rnorm(100)
, x<-rnorm(100)
,
I would like to create a vector that stores the position of the first, second, third...100th highest value in X. 我想创建一个向量,存储X中第一个,第二个,第三个......第100个最高值的位置。
For example if x=4,9,2,0,10,11
then the desired vector would be 6,5,2,1,3,4
is there a function for doing this? 例如,如果x=4,9,2,0,10,11
那么期望的向量将是6,5,2,1,3,4
是否有这样做的功能?
Try using order
尝试使用order
> order(x, decreasing =TRUE)
[1] 6 5 2 1 3 4
Try this: 尝试这个:
> order(-x)
[1] 6 5 2 1 3 4
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.