ggbarcrosstabs {ggsurvey} | R Documentation |
Crosstabs of Two Variables
Description
In ggsurvey you specify both the plotting variables and weights in plain text with no quotes. This function creates a crosstab of x by a second variable y.
Usage
ggbarcrosstabs(df, x, y, weights, fill = NULL, labeller = NULL)
Arguments
df |
data frame of survey |
x |
variable to bar chart |
y |
faceting variable |
weights |
survey weights that sum to sample size |
fill |
if true the fill of each bar will be a different color corresponding to the level of the factor |
labeller |
argument to pass onto facet_grid |
Value
ggplot object
Examples
library(survey)
data(api)
ggbarcrosstabs(apistrat, stype, yr.rnd, pw)+ylab("Proportion")
ggbarcrosstabs(apistrat, stype, yr.rnd, pw, fill = TRUE)+ylab("Proportion")
data(nhanes)
ggbarcrosstabs(nhanes, race, agecat, WTMEC2YR)
[Package ggsurvey version 1.0.0 Index]