quantile(x, ...) quantile.default(x, probs = 0:4/4, na.rm = FALSE, names = TRUE, type = 7, ...)
x | a numeric vector. Missing values (NAs) are only allowed if you set na.rm = TRUE. |
probs | a vector of desired probability levels where the values are must be between or equal to 0 and 1. The default value, seq(0, 1, 0.25), produces a "five number summary" that includes: the minimum, lower quartile, median, upper quartile, and maximum of x. |
na.rm | a logical value that specifies if missing values (NAs) are removed before the function performs the computation. |
names | a logical value that specifies if a "names" attribute should be included in the result. |
type | an integer value between 1 and 9 that is used to select one quantile algorithm. For more information about the definition of each value, see the Details section. |
... | methods may have other arguments. The following arguments are available in the default method. |
type | Calculation |
1 | y = 0 if g = 0, and 1 otherwise. |
2 | y = 0.5 if g = 0, and 1 otherwise. |
3 | SAS definition: nearest even order statistic. y = 0 if g = 0 and j is even, and 1 otherwise. |
type | Calculation |
4 | m = 0. p[k] = k / n. |
5 | m = 1/2. p[k] = (k - 0.5) / n. |
6 | m = p. p[k] = k / (n + 1). Thus p[k] = E[F(x[k])]. This is used by Minitab and by SPSS. |
7 | m = 1-p. p[k] = (k - 1) / (n - 1). In this case, p[k] = mode[F(x[k])]. This is used by S. |
8 | m = (p+1)/3. p[k] = (k - 1/3) / (n + 1/3). Then p[k] =~ median[F(x[k])]. |
9 | m = p/4 + 3/8. p[k] = (k - 3/8) / (n + 1/4). |
quantile(1:9) # 0% 25% 50% 75% 100% # 1 3 5 7 9
quantile(1:9, probs=seq(0,1,.1)) # 0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100% # 1.0 1.8 2.6 3.4 4.2 5.0 5.8 6.6 7.4 8.2 9.0
quantile(1:9, probs=c(0.1,0.3,NA,NA)) # 10% 30% # 1.8 3.4 NA NA