3

Possible Duplicate:
How to see the source code of R .Internal or .Primitive function?

I'm searching for the C source used to compute R's rank function

I've looked in the R/src/main/ directory and i can't find it. Does anyone know where i can find the source code for what R calls when i use R's internal rank function? e.g. what is called when one does .Internal(rank(x,"average")).

Alternatively, i would like to ensure that the efficient way to get the rank vector corresponding to a vector of floats is to first sort them.

Community
  • 1
  • 1
user189035
  • 5,589
  • 13
  • 52
  • 112

1 Answers1

5

It is in /src/main/sort.c, about 90% of the way down the file:

/* FUNCTION: rank(x, length, ties.method) */
SEXP attribute_hidden do_rank(SEXP call, SEXP op, SEXP args, SEXP rho)
{

In future, you can search through the sources using a tool like find or grep as supplied with your OS to locate these things (or likely places to look).

See also, Uwe Ligge's article in R News on how to go about searching for things in R's sources: Uwe Ligges. R Help Desk: Accessing the sources. R News, 6(4):43-45, October 2006

Gavin Simpson
  • 170,508
  • 25
  • 396
  • 453