Learn R Programming

weights (version 1.1.1)

wtd.quantile: Weighted quantiles

Description

wtd.quantile computes quantiles from a numeric vector using observation weights.

Usage

wtd.quantile(x, weight = NULL, probs = c(0.25, 0.5, 0.75), na.rm = TRUE)

Value

A named numeric vector of quantiles.

Arguments

x

Numeric vector of values.

weight

Optional numeric vector of weights.

probs

Numeric vector of quantile probabilities (between 0 and 1).

na.rm

Logical. If TRUE, removes missing values.

Author

Josh Pasek

See Also

quantile, wtd.median

Examples

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

Run the code above in your browser using DataLab