weighted_median: Weighted Median

View source: R/statistics.R

weighted_medianR Documentation

Weighted Median

Description

Calculates weighted median based on weighted_quantile().

Usage

weighted_median(x, w = NULL, ...)

Arguments

x

Numeric vector.

w

Optional vector of non-negative case weights.

...

Further arguments passed to weighted_quantile().

Value

A length-one numeric vector.

See Also

weighted_quantile()

Examples

n <- 21
x <- seq_len(n)
quantile(x, probs = 0.5)
weighted_median(x, w = rep(1, n))
weighted_median(x, w = x)
quantile(rep(x, x), probs = 0.5)

MetricsWeighted documentation built on Nov. 16, 2023, 5:09 p.m.