x <- c(1,3,4,8,12,13,18,20)
quantile(x, c(0.25, 0.5))
quantilew(x, c(0.25, 0.5), weights=1:8) ## 8 13
## relative weights (1+2+3)/36 sum to <0.25 , with the forth, they
## are over 0.25, therefore, the quantile is the 4th value
Run the code above in your browser using DataLab