wtd_median: Weighted median

Description Usage Arguments Details Value See Also Examples

View source: R/wtd_median.R

Description

Compute the median of x weighted by weights.

Usage

1

Arguments

x

a numerical vector.

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 a missing value as the result.

Value

The weighted median of x.

See Also

Other weighted statistics: wtd_mean(), wtd_quantile()

Examples

1
wtd_median(1:5, weights = 5:1)

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