-2

How is a quantile calculated in R language? I have looked up for a solution but the site said that quantile = p*(n+1) where p is the percentage ani n is the number of rows in a dataset. I am not getting the right answer. Can anyone please help me.

iamnexxed
  • 15
  • 6
  • 2
    Read help("quantile").There are actually many ways of calculating quantiles and R implements quite a few of them. – Roland Oct 27 '18 at 10:46

1 Answers1

0

Try this:

x <- rnorm(100) # sample data
quantile(x)  # quartiles 
quantile(x, c(0.1, 0.9))  # 10th and 90th centiles

There are a number of ways to find out about how to do things in R, for example, introductory books (many of them online, e.g., https://cran.r-project.org/other-docs.html) and simple functions such as apropos and RSiteSearch:

apropos("foo") # gives you a list of functions that have "foo" in their name
lebatsnok
  • 6,329
  • 2
  • 21
  • 22
  • Can you suggest me what formula is being used so that I can verify my results – iamnexxed Oct 27 '18 at 10:52
  • I suggest having a look at `?quantile` or `help(quantile)` as Roland suggested. The computational methods are described there, with references ("`quantile` returns estimates of underlying distribution quantiles based on one or two order statistics from the supplied elements in x at probabilities in probs. One of the nine quantile algorithms discussed in Hyndman and Fan (1996), selected by type, is employed." .... etc) -- type is an extra parameter to `quantile` - you can select between 9 algorithms – lebatsnok Oct 27 '18 at 11:30