Dear R-users,
a very easy one for you, I guess. I need to extract the indexes of the
elements corresponding to different quantiles of a vector. When a
quantile is an interpolation between two adjacent values, I need the
index of the value which is closer (the lower value - or the higher
value for what matters - in case the quantile is exactly half way
through).

This is an example.

> x <- c(9,9,1,3,2,7,6,10,5,6)
> quantile(x)
  0%  25%  50%  75% 100%
 1.0  3.5  6.0  8.5 10.0

What I need is a vector 'index' which looks like

> index
3   4   7   1   8

Many thanks for your help ! Matteo

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to