Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rcpp sugar for rank function

I have been trying to get the rank of a vector in c++ using Rcpp. I have used other sugar functions like

is_na();

Is there a similar sugar function for rank R function in c++. Also is there any list of available R sugar functions in Rcpp/

like image 574
gman Avatar asked Jan 10 '23 15:01

gman


1 Answers

1) There is an order function here and order(order(x)) is rank(x, ties = "first").

2) A second way would be: match(x, sort(x))

ADDED Second approach.

like image 164
G. Grothendieck Avatar answered Jan 18 '23 13:01

G. Grothendieck