Skip to contents

This function computes the *midrange* score, i.e. the average of the lowest and highest values in a set of data. See the **Details** section below for further information.

Usage

midrange(x, i = NULL, na.rm = T)

Arguments

x

(named) numerical vector

i

(optional) numerical vector giving the position in x or character vector matching the names in x. If missing or i = NULL, the entire x is considered for the computation of the score

na.rm

logical, whether to remove NA values from x before computation

Value

A numerical value representing the computed measure. A default NA value is returned if the score can't be computed.

Details

The midrange score is a measure of central tendency like the mean, median, and mode. However, it is more prone to bias than these other measures because it relies solely upon the two most extreme scores, which could potentially be outliers.

References

https://dictionary.apa.org/midrange

Author

Alessandro Barberis

Examples

x = c(0,1,1,2,3,3,3,100,NA)
midrange(x = x, na.rm = TRUE)
#> [1] 50