Skip to content
Prev 131339 / 398503 Next

R function for percentrank

On Wed, 2007-12-05 at 18:42 +0100, Martin Maechler wrote:
Martin,

Thanks for the corrections. In hindsight, now seeing the intended use of
ecdf() in the fashion you describe above, it is now clear that my
approach in response to David's query was un-needed and "over the top".
"Yuck" is quite appropriate... :-)

As I was going through this "exercise", it did seem overly complicated,
given R's usual elegant philosophy about such things. I suppose if I had
looked at the source for plot.stepfun(), it would have been more evident
as to how the y values are acquired.

In reviewing the examples in ?ecdf, I think that an example using
something along the lines of the discussion here more explicitly, would
be helpful. It is not crystal clear from the examples, that one can use
ecdf() in this fashion, though the use of "12 * Fn(tt)" hints at it.

Perhaps:

##-- Simple didactical  ecdf  example:
x <- rnorm(12)
Fn <- ecdf(x)
Fn
Fn(x)  # returns the percentiles for x
...


Thanks again Martin and no offense taken...  :-)

Regards,

Marc