weighted.median: Compute the median of weighted data.

Description Usage Arguments Details Examples

View source: R/weighted-stats.r

Description

Compute the median of weighted data.

Usage

1
weighted.median(x, w, na.rm = FALSE)

Arguments

x

numeric vector of observations

w

integer vector of weights, representing the number of time each x was observed

na.rm

If TRUE will automatically remove missing values in x or w.

Details

This is a simple wrapper around weighted.quantile

Examples

1
2
3
4
5
x <- runif(200)
w <- rpois(200, 5) + 1

median(x)
weighted.median(x, w)

hadley/bigvis documentation built on May 17, 2019, 9:45 a.m.