John,

The Excel's percentrank function works like this: if one has a number, x for
example, and one wants to know the percentile of this number in a given data
set, dataset, one would type =percentrank(dataset,x) in Excel to calculate
the percentile. So for example, if the data set is c(1:10), and one wants to
know the percentile of 2.5 in the data set, then using the percentrank
function one would get 0.166, i.e., 2.5 is in the 16.6th percentile.

I am not sure how to program this function in R. I couldn't find it as a
built-in function in R either. It seems to be an obvious choice for a
built-in function. I am very surprised, but maybe we both missed it.


On 12/1/07, John Kane <[EMAIL PROTECTED]> wrote:
>
> I don't see one but that means nothing.   I think you
> can write such a function in a few minutes
>
> Will something like this work or am I
> missunderstanding what Excel's percentrank does ?
>
> aa <- rnorm(25);  aa  # data vector
> percentrank <- function(x) {
> var  <- sort(x)
> p.rank <- 1:length(var)/length(var)*100
> dd  <- cbind(var,p.rank)
> }
> pr <- percentrank(aa); pr
>
>
> --- tom soyer <[EMAIL PROTECTED]> wrote:
>
> > Hi,
> >
> > Does anyone know if R has a built-in function that
> > is equvalent to Excel's
> > percentrank, i.e., returns the rank of a value in a
> > data set as a percentage
> > of the data set?
> >
> > Thanks,
> >
> > --
> > Tom
> >
> >       [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained,
> > reproducible code.
> >
>
>
>
>      Ask a question on any topic and get answers from real people. Go to
> Yahoo! Answers and share what you know at http://ca.answers.yahoo.com
>



-- 
Tom

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to