powered by
Computes median of ordered factor or numeric variable taking into account weights.
medianf(X, W = rep(1, length(X)))
The median category (number or label) of ordered factor.
is a data vector (numeric or ordered factor)
is a vector of weights
Calculates median based on cumulative distribution. Tailored for ordered factors.
# 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)
Run the code above in your browser using DataLab