wtd_quantile: Weighted quantiles

Description Usage Arguments Details Value See Also Examples

View source: R/wtd_quantile.R

Description

Compute the quantiles of x weighted by weights.

Usage

1
wtd_quantile(x, probs, weights = NULL)

Arguments

x

a numerical vector.

probs

a numerical vector with the quantile probabilities.

weights

a numerical vector of weights the same length as x.

Details

If weights is NULL, all elements of x receive the same weight. Observations with zero weights are omitted from the computation. Missing values are not handled specially and produce missing values as the result.

Value

A numeric vector with the weighted quantiles of x.

See Also

Other weighted statistics: wtd_mean(), wtd_median()

Examples

1
wtd_quantile(1:5, weights = 5:1, probs = (1:4)/5)

jcpernias/ec1047 documentation built on Nov. 19, 2020, 2:33 a.m.