Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get nth percentile using R summary?

Tags:

r

I can use R summary function to get min, max and percentiles(25, 75).

How can i use summary to get arbitrary quantiles like 90th percentile and 99th percentile in summary stats?

like image 414
Sathish Avatar asked Mar 27 '13 13:03

Sathish


People also ask

How do you find the nth percentile in R?

You find a percentile in R by using the quantiles function. It produces the percentage with the value that is the percentile. This is the default version of this function, and it produces the 0th percentile, 25th percentile, 50th percentile, 75th percentile, and 100th percentile.

How do you find the 2.5th percentile in R?

For this purpose, we can use quantile function in R. To find the 2.5th percentile, we would need to use the probability = 0.025 and for the 97.5th percentile we can use probability = 0.0975.

What is percentile value in R?

The nth percentile of an observation variable is the value that cuts off the first n percent of the data values when it is sorted in ascending order.

How do you find the percentile of a normal distribution in R?

We obtain percentile values in R using the function qnorm. This function returns the value of the standard normal (by default) distribution corresponding to a given percentile. For example, qnorm(. 5) returns 0, the median of the standard normal distribution.


1 Answers

Use quantile function

quantile(x, c(.90, .99)) 

Example:

> set.seed(1) > x <- rnorm(100) > summary(x)    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.  -2.2150 -0.4942  0.1139  0.1089  0.6915  2.4020  > quantile(x, c(.25, .50,  .75, .90, .99))        25%        50%        75%        90%        99%  -0.4942425  0.1139092  0.6915454  1.1810651  2.1749017  
like image 130
Jilber Urbina Avatar answered Sep 23 '22 12:09

Jilber Urbina