Calculates the five number summary of a vector of data or of each column of a matrix of data, using the estimators of the lower quartile, median and upper quartile in the STAT002 notes.
five_number(x, type = 6, na.rm = FALSE)
A numeric vector (if the input was a vector) or matrix (if the input was a matrix).
The five number summary contains the sample minimum and maximum and
estimates of the lower quartile, median and upper quartile, i.e. the
25%, 50% and 75% quantiles. These quantiles are estimated using the
quantile
function. By default, type = 6
is
used in the call to quantile
in order to use the estimator defined
in the STAT002 notes.
quantile
for calculating sample quantiles.
birth_times <- ox_births[, "time"]
five_number(birth_times)
#> min 25% 50% 75% max
#> 1.50 4.90 7.50 9.75 19.00
# Note: summary() uses type = 7 in the call to quantile()
five_number(birth_times, type = 7)
#> min 25% 50% 75% max
#> 1.50 4.95 7.50 9.75 19.00
summary(birth_times)
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> 1.500 4.950 7.500 7.723 9.750 19.000