How can I calculate sample 90th percentile?

I used "quantile" function but could not figure out how to calculate a sample 90th percentile with it. Thank you!

quantile(rnorm(100), probs = .9)

1 Like

Hi, and welcome!

Please see the FAQ: What's a reproducible example (`reprex`) and how do I do one? Using a reprex, complete with representative data will attract quicker and more answers. For this question, it's easy to come up with an example from standard data sets, but that won't always be the case.

suppressPackageStartupMessages(library(dplyr)) 
# construct a numeric vector from the iris built-in dataset
iris %>% select(Sepal.Length) -> sl
sl$Sepal.Length -> sl
# return the required percentile
quantile(sl,0.9)
#> 90% 
#> 6.9

Created on 2020-03-22 by the reprex package (v0.3.0)

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.