Aliases: quantile quantile.default
Keywords: univar
### ** Examples quantile(x <- rnorm(1001)) # Extremes & Quartiles by default
0% 25% 50% 75% 100% -3.05790772 -0.66412121 0.05109669 0.70562766 2.81242952
quantile(x, probs = c(0.1, 0.5, 1, 2, 5, 10, 50, NA)/100)
0.1% 0.5% 1% 2% 5% 10% -2.78974249 -2.41338591 -2.26193395 -1.97274587 -1.58841890 -1.21404169 50% 0.05109669 NA
### Compare different types quantAll <- function(x, prob, ...) t(vapply(1:9, function(typ) quantile(x, probs = prob, type = typ, ...), quantile(x, prob, type=1, ...))) p <- c(0.1, 0.5, 1, 2, 5, 10, 50)/100 signif(quantAll(x, p), 4)
0.1% 0.5% 1% 2% 5% 10% 50% [1,] -2.790 -2.413 -2.262 -1.973 -1.588 -1.214 0.05110 [2,] -2.790 -2.413 -2.262 -1.973 -1.588 -1.214 0.05110 [3,] -3.058 -2.414 -2.267 -1.985 -1.589 -1.215 0.05074 [4,] -3.058 -2.414 -2.267 -1.985 -1.589 -1.215 0.05092 [5,] -2.924 -2.414 -2.264 -1.979 -1.589 -1.214 0.05110 [6,] -3.057 -2.414 -2.267 -1.985 -1.589 -1.215 0.05110 [7,] -2.790 -2.413 -2.262 -1.973 -1.588 -1.214 0.05110 [8,] -2.968 -2.414 -2.265 -1.981 -1.589 -1.215 0.05110 [9,] -2.957 -2.414 -2.265 -1.980 -1.589 -1.215 0.05110
## 0% and 100% are equal to min(), max() for all types: stopifnot(t(quantAll(x, prob=0:1)) == range(x)) ## for complex numbers: z <- complex(real = x, imaginary = -10*x) signif(quantAll(z, p), 4)
0.1% 0.5% 1% 2% 5% [1,] -2.79+27.90i -2.41+24.13i -2.26+22.62i -1.97+19.73i -1.59+15.88i [2,] -2.79+27.90i -2.41+24.13i -2.26+22.62i -1.97+19.73i -1.59+15.88i [3,] -3.06+30.58i -2.41+24.14i -2.27+22.67i -1.99+19.85i -1.59+15.89i [4,] -3.06+30.58i -2.41+24.14i -2.27+22.67i -1.99+19.85i -1.59+15.89i [5,] -2.92+29.24i -2.41+24.14i -2.26+22.64i -1.98+19.79i -1.59+15.89i [6,] -3.06+30.57i -2.41+24.14i -2.27+22.67i -1.98+19.85i -1.59+15.89i [7,] -2.79+27.90i -2.41+24.13i -2.26+22.62i -1.97+19.73i -1.59+15.88i [8,] -2.97+29.68i -2.41+24.14i -2.27+22.65i -1.98+19.81i -1.59+15.89i [9,] -2.96+29.57i -2.41+24.14i -2.27+22.65i -1.98+19.80i -1.59+15.89i 10% 50% [1,] -1.21+12.14i 0.0511-0.5110i [2,] -1.21+12.14i 0.0511-0.5110i [3,] -1.22+12.15i 0.0507-0.5074i [4,] -1.21+12.15i 0.0509-0.5092i [5,] -1.21+12.14i 0.0511-0.5110i [6,] -1.21+12.15i 0.0511-0.5110i [7,] -1.21+12.14i 0.0511-0.5110i [8,] -1.21+12.15i 0.0511-0.5110i [9,] -1.21+12.15i 0.0511-0.5110i