Consider the following vector:
vec = rnorm(1000)
I would like to compute the quintiles of this vector, and then average the vector values for each quintile.
I know the way of getting the quantiles is:
qtle = quantile(vec, seq(from = 0, to = 1, by = 0.2)
but I am not sure how to compute the mean of the values within each quantile (i.e. the mean of the bottom 20%, the mean of the next 20%, etc.) in an efficient manner.
Any ideas?
Thanks.