Skip to content
Back to formatted view

Raw Message

Message-ID: <243517.68093.qm@web32807.mail.mud.yahoo.com>
Date: 2007-12-01T16:33:12Z
From: John Kane
Subject: R function for percentrank
In-Reply-To: <65cc7bdf0712010337o5844e1a3sfcb6984f93946267@mail.gmail.com>

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 <tom.soyer at gmail.com> 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 at 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.
>