medianf {wINEQ} | R Documentation |
Median of ordered factor or numeric
Description
Computes median of ordered factor or numeric variable taking into account weights.
Usage
medianf(X, W = rep(1, length(X)))
Arguments
X |
is a data vector (numeric or ordered factor) |
W |
is a vector of weights |
Details
Calculates median based on cumulative distribution. Tailored for ordered factors.
Value
The median category (number or label) of ordered factor.
Examples
# 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)
[Package wINEQ version 1.2.0 Index]