Skip to contents

Computes the weighted median of a numeric vector given weights. Use for summarizing survey or model outputs.

Usage

weighted.median(x, w)

Arguments

x

numeric vector. Values to summarize.

w

numeric vector. Weights for each value.

Value

numeric(1). Weighted median value.

Details

  • Calls weighted.percentile with p = 0.5.

  • Returns weighted median value.

Settings

None.

See also

weighted.percentile

Other utility functions: archive_file(), clip.vector(), fillna(), weighted.percentile()

Examples

weighted.median(c(1, 2, 3), c(0.2, 0.5, 0.3))
#> [1] 2