R/weighted_IQR.R

Defines functions weighted_IQR

Documented in weighted_IQR

# weighted interquartile range
weighted_IQR <- function(x, w, na.rm = FALSE, constant = 0.7413)
{
    dat <- .check_data_weights(x, w, na.rm)
    if (is.null(dat))
        return(NA)
    qs <- weighted_quantile(dat$x, dat$w, probs = c(0.25, 0.75), na.rm)
    unname((qs[2] - qs[1]) * constant)
}

Try the robsurvey package in your browser

Any scripts or data that you put into this service are public.

robsurvey documentation built on Jan. 6, 2023, 5:09 p.m.