0

Given a set of real numbers stored in a data frame df under a column A, and an element r in this set, how would you solve the following 'equation' for q:

r = quantile(df$A, q)

Thanks for any help.

Roland
  • 127,288
  • 10
  • 191
  • 288
user1873334
  • 207
  • 2
  • 8
  • possible duplicate of [How do I calculate the probability for a given quantile in R?](http://stackoverflow.com/questions/9123800/how-do-i-calculate-the-probability-for-a-given-quantile-in-r) – Waldir Leoncio Feb 14 '14 at 13:50

1 Answers1

5

In ?quantile we can read

See Also

ecdf for empirical distributions of which quantile is an inverse

Thus:

x <- rnorm(100)

r <- quantile(x, 0.05)
#       5% 
#-1.469996 

Fn <- ecdf(x)
Fn(r)
#[1] 0.05
Community
  • 1
  • 1
Roland
  • 127,288
  • 10
  • 191
  • 288