survey_IQR {iNZightTools} | R Documentation |
Interquartile range function for surveys
Description
Calculates the interquartile range from complex survey data.
A wrapper for taking differences of svyquantile
at 0.25 and 0.75 quantiles,
and meant to be called from within summarize
(see srvyr package).
Usage
survey_IQR(x, na.rm = TRUE)
Arguments
x |
A variable or expression |
na.rm |
logical, if |
Value
a vector of interquartile ranges
Author(s)
Tom Elliott
Examples
library(survey)
library(srvyr)
data(api)
dstrata <- apistrat %>%
as_survey(strata = stype, weights = pw)
dstrata %>%
summarise(api99_iqr = survey_IQR(api99))
[Package iNZightTools version 2.0.1 Index]