powered by
Computes the weighted median of a numeric vector.
weightedMedian(x, w)
Weighted median of x with respect to w.
Numeric vector.
Integer vector of weights.
Here, the median of an even length \(n\) of \(x\) is defined as \(x_{(n/2 + 1)}\) if \(x_{(i)}\) is the \(i\)-th largest element in \(x\), i.e. the larger value is taken.
x <- c(1, 4, 9) w <- c(5, 1, 1) weightedMedian(x, w)
Run the code above in your browser using DataLab