for the mtcars sample. I want to get the corresponding mpg value for each quantiles of wt. See code below.
> quantile(mtcars$wt, c(.15,.3,.45,.6,.75,.9),na.rm=T)
   15%    30%    45%    60%    75%    90% 
2.1790 2.7730 3.1890 3.4400 3.6100 4.0475
So in the code above I have the .15, .3, .45, .6, .75, and .9 quantiles for mtcars$wt. And I want to get the corresponding values for mtcars$mpg for each quantiles of the mtcars$wt above.
I tried this code but definitely does not work.
mtcars$mpg[quantile(mtcars$wt, c(.15,.3,.45,.6,.75,.9),na.rm=T)]
 
    