4

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/

gman
  • 1,242
  • 2
  • 16
  • 29
  • Hadley has list of sugar functions: http://adv-r.had.co.nz/Rcpp.html#rcpp-sugar But I don't know how exhaustive it is. It shouldn't be too difficult to write your own rank function. – Roland May 12 '14 at 11:05
  • Thank you for the list and Ya its easy to implement my own rank(). – gman May 12 '14 at 12:18

1 Answers1

9

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.

Community
  • 1
  • 1
G. Grothendieck
  • 254,981
  • 17
  • 203
  • 341