if (FALSE) { # requireNamespace("survey")
data(api, package = "survey")
dstrat <- survey::svydesign(
id = ~1, strata = ~stype,
weights = ~pw, data = apistrat,
fpc = ~fpc
)
ggsurvey(dstrat) +
ggplot2::aes(x = cnum, y = dnum) +
ggplot2::geom_count()
d <- as.data.frame(Titanic)
dw <- survey::svydesign(ids = ~1, weights = ~Freq, data = d)
ggsurvey(dw) +
ggplot2::aes(x = Class, fill = Survived) +
ggplot2::geom_bar(position = "fill")
}
Run the code above in your browser using DataLab