five_number: Five number summary

View source: R/descriptive_statistics.R

five_numberR Documentation

Five number summary

Description

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.

Usage

five_number(x, type = 6, na.rm = FALSE)

Arguments

x

A numeric vector or matrix.

type

Argument type used in the call to quantile to estimate the 25%, 50% and 75% quantiles.

na.rm

A logical scalar. If true, any NA and NaNs are removed from x before the sample quantiles are computed.

Details

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.

Value

A numeric vector (if the input was a vector) or matrix (if the input was a matrix).

See Also

quantile for calculating sample quantiles.

Examples

birth_times <- ox_births[, "time"]
five_number(birth_times)

# Note: summary() uses type = 7 in the call to quantile()
five_number(birth_times, type = 7)
summary(birth_times)

paulnorthrop/stat0002 documentation built on Oct. 10, 2024, 1:27 p.m.