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