# NOT RUN {
library(survey)
library(dplyr)
data(api)
dstrata <- apistrat %>%
as_survey_design(strata = stype, weights = pw)
dstrata %>%
summarise(api99_unw = unweighted(mean(api99)),
n = unweighted(n()))
dstrata %>%
group_by(stype) %>%
summarise(api_diff_unw = unweighted(mean(api00 - api99)))
# }
Run the code above in your browser using DataCamp Workspace