Description Usage Arguments Value Examples
Creates a summarized data frame out of a raw dataframe ready for ggplot2 charting.
1 2 |
df |
A raw data frame that includes a subgroup variable, a variable to be tested, and optionally a weight variable. |
x |
A factor or numeric variable name to be charted, in quotes. |
subgroup |
A factor variable name that subgroups cases, in quotes. |
weight |
Optional. A post-stratification weight variable name, in quotes. |
nlabels |
A logical argument. Default is FALSE. If TRUE, the subgroup levels will be changed to include the unweighted sample sizes ("subgroup (n=xx)"). |
newline |
A logical argument. Default is FALSE. If TRUE, the unweighted sample sizes will be shown on a separate line. |
A summary data frame ready for ggplot2 charting that provides each group's sample sizes and their proportions for each level of the variable (if the variable is a factor) or their means (if the variable is a numeric).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | #Prepping the data first
gss_data1 <- dplyr::filter(gss_data, year == "2016",
conlegis %in% c("A GREAT DEAL", "ONLY SOME", "HARDLY ANY"))
#Factor variable with weights
tbl_chart(gss_data1, "conlegis", "region", "wtssall")
#Factor variable without weights
tbl_chart(gss_data1, "conlegis", "region")
#Numeric variable with weights
tbl_chart(gss_data1, "coninc", "region", "wtssall")
#Numeric variable without weights
tbl_chart(gss_data1, "coninc", "region")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.