View source: R/inequalityMeasure.R
medianf | R Documentation |
Computes median of ordered factor or numeric variable taking into account weights.
medianf(X, W = rep(1, length(X)))
X |
is a data vector (numeric or ordered factor) |
W |
is a vector of weights |
Calculates median based on cumulative distribution. Tailored for ordered factors.
The median category (number or label) of ordered factor.
# Compare weighted and unweighted result
X=factor(c('H','H','M','M','L','L'),levels = c('L','M','H'),ordered = TRUE)
W=c(2,2,3,3,8,8)
medianf(X)
medianf(X,W)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.