Skip to contents

median_range() computes the minimal and maximal possible median values. This is helpful if median2() returns NA: the median can't be determined, but at least its bounds might be known.

Usage

median_range(x, na.rm.amount = 0, even = c("mean", "low", "high"))

# S3 method for default
median_range(x, na.rm.amount = 0, even = c("mean", "low", "high"))

Arguments

x

Numeric or similar. Vector to search for its possible medians.

na.rm.amount, even

Passed on to median2().

Value

Vector of length 2 and the same type as x.

If the median can be determined (i.e., median2() would return a non-NA value), median_range() returns two identical values.

If there are missing values at the median position, the median range cannot be determined. The function will then return c(NA, NA).

Details

Like median2(), this function is generic, so methods can be defined for other classes. This documentation describes the default method.

Author

Lukas Jung, R Core Team

Examples

median_range(c(7, 7, 8, 9, NA))
#> [1] 7 8
median_range(c(7, 7, 7, 8, 9, 9, NA, NA))
#> [1] 7.0 8.5