data vector to corresonding percentile ranks
On Dec 23, 2011, at 10:28 AM, Steve Jones wrote:
I have a problem where I need to calculate the corresponding cohort percentile ranks for each of several variables. Essentially, what I need is a function that will calculate the distribution-free percentiles from each variable's data vector, returning a corresponding vector of percentiles: e.g.: percentile.my.data<-/function/(my.data) I tried to make ecdf() perform this task but was unsuccessful.
Unsuccessful? How? Seems like a reasonable strategy: set.seed(123) x <- rnorm(1000) xCdist <- ecdf(x) Seems to give sensible results. > x[1] [1] -0.7104066 > 100*xCdist(x[1]) [1] 23.4 > x[2] [1] 0.2568837 > 100*xCdist(x[2]) [1] 60
I'd be grateful for any help or advice...
My advice would be to post what code you were trying so that you can get help understand what difficulties you need to overcome.
David Winsemius, MD West Hartford, CT