library(survey)
data(api)
dstrata <- apistrat %>%
as_survey_design(strata = stype, weights = pw)
dstrata %>%
summarise(enroll = survey_ratio(api00, api99, vartype = c("ci", "cv")))
dstrata %>%
group_by(awards) %>%
summarise(api00 = survey_ratio(api00, api99))
# level takes a vector for multiple levels of confidence intervals
dstrata %>%
summarise(enroll = survey_ratio(api99, api00, vartype = "ci", level = c(0.95, 0.65)))Run the code above in your browser using DataLab