# NOT RUN {
gf_bar(~substance, data = mosaicData::HELPrct)
gf_bar(~substance, data = mosaicData::HELPrct, fill = ~sex)
gf_bar(~substance,
data = mosaicData::HELPrct, fill = ~sex,
position = position_dodge()
)
# gf_counts() is another name for gf_bar()
gf_counts(~substance,
data = mosaicData::HELPrct, fill = ~sex,
position = position_dodge()
)
# gf_props() and gf_percents() use proportions or percentages instead of counts
# use denom to control which denominators are used.
gf_props(~substance,
data = mosaicData::HELPrct, fill = ~sex,
position = position_dodge()
)
gf_props(substance ~ .,
data = mosaicData::HELPrct, fill = ~sex,
position = position_dodge(),
orientation = 'y'
)
gf_propsh(substance ~ .,
data = mosaicData::HELPrct, fill = ~sex,
position = position_dodgev(),
)
gf_percents(~substance,
data = mosaicData::HELPrct, fill = ~sex,
position = position_dodge()
)
gf_percents(~substance,
data = mosaicData::HELPrct, fill = ~sex,
position = position_dodge(),
denom = ~x
)
gf_percents(~substance,
data = mosaicData::HELPrct, fill = ~sex,
position = position_dodge(),
denom = ~fill
)
gf_percents(~substance | sex,
data = mosaicData::HELPrct, fill = ~homeless,
position = position_dodge()
)
gf_percents(~substance | sex,
data = mosaicData::HELPrct,
fill = ~homeless,
denom = ~fill,
position = position_dodge()
)
gf_percents(~substance | sex,
data = mosaicData::HELPrct,
fill = ~homeless,
denom = ~interaction(fill, PANEL),
position = position_dodge()
)
if (require(scales)) {
gf_percents(~substance,
data = mosaicData::HELPrct, fill = ~sex,
position = position_dodge(),
denom = ~ x,
) %>%
gf_refine(scale_y_continuous(labels = scales::percent))
}
# }
Run the code above in your browser using DataLab