Calculate quantiles in R without interpolation - round up or down to actual value -
it's understanding when calculating quantiles in r, entire dataset scanned , value each quantile determined.
if ask .8, example give value occur @ quantile. if no such value exists, r nonetheless give value would have occurred @ quantile. through linear interpolation.
however, if 1 wishes calculate quantiles , proceed round up/down nearest actual value?
for example, if quantile @ .80 gives value of 53, when real dataset has 50 , 54, how 1 r list either of these values?
try this:
#dummy data x <- c(1,1,1,1,10,20,30,30,40,50,55,70,80) #get quantile @ 0.8 q <- quantile(x, 0.8) q # 80% # 53 #closest match - "round up" min(x[ x >= q ]) #[1] 55 #closest match - "round down" max(x[ x <= q ]) #[1] 50