# NOT RUN {
# Example 1 ----------------------------------
# A simple weighted dataset
add_p_svysummary_ex1 <-
survey::svydesign(~1, data = as.data.frame(Titanic), weights = ~Freq) %>%
tbl_svysummary(by = Survived) %>%
add_p()
# A dataset with a complex design
data(api, package = "survey")
d_clust <- survey::svydesign(id = ~dnum, weights = ~pw, data = apiclus1, fpc = ~fpc)
# Example 2 ----------------------------------
add_p_svysummary_ex2 <-
tbl_svysummary(d_clust, by = both, include = c(cname, api00, api99, both)) %>%
add_p()
# Example 3 ----------------------------------
# change tests to svy t-test and Wald test
add_p_svysummary_ex3 <-
tbl_svysummary(d_clust, by = both, include = c(cname, api00, api99, both)) %>%
add_p(
test = list(
all_continuous() ~ "svy.t.test",
all_categorical() ~ "svy.wald.test"
)
)
# }
Run the code above in your browser using DataLab