Learn R Programming

weights (version 1.1.1)

wtd.median: Weighted median

Description

wtd.median computes the median of a numeric vector using weights.

Usage

wtd.median(x, weight = NULL, na.rm = TRUE)

Value

A single numeric value representing the weighted median.

Arguments

x

Numeric vector of values.

weight

Optional numeric vector of weights.

na.rm

Logical. If TRUE, removes missing values.

Author

Josh Pasek

See Also

wtd.quantile, median

Examples

Run this code
x <- c(1, 2, 3, 4, 5)
w <- c(1, 1, 5, 1, 1)
wtd.median(x, weight = w)

Run the code above in your browser using DataLab