I do not understand all the terminology inside R. I have only 100 level statistics, trying to learn more.
I am guessing R has a built-in percentile function named something I don't recognize or know how to search for.
I can write my own, but rather use the built in one for obvious reasons.
Here's the one I wrote:
percentile <- function(x) return((x - min(x)) / (max(x) - min(x))
You can do this via
scale(x,center=min(x,na.rm=TRUE),scale=diff(range(x,na.rm=TRUE)))
but I'm not sure there is actually a built-in function that does the scaling you're asking for.
If you are looking to find out specific percentiles from a data set, take a look at the quantile
function: ?quantile
. By multiplying by 100, you get percentiles.
If you are looking into converting numbers to their percentiles, take a look at rank
, though you will need to determine how to address ties. You can simply rescale from rank to quantile by dividing by the length of the vector.
The quantile
function might be what you are looking for. If you have vector x
and you want to know the 25th, 43rd, and 72nd percentiles you would execute this:
quantile(x, c(.25, .43, .72));
The semicolon is, of course, optional.
See http://www.r-tutor.com/elementary-statistics/numerical-measures/percentile
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With