Description Usage Arguments Details Value Examples
moe_crosstab
returns a tibble containing a weighted crosstab of two variables with margin of error
1 2 3 4 5 6 7 8 9 10 11 12 |
df |
The data source |
x |
The independent variable |
y |
The dependent variable |
weight |
The weighting variable, defaults to zwave_weight |
remove |
An optional character vector of values to remove from final table (e.g. "refused"). This will not affect any calculations made. The vector is not case-sensitive. |
n |
logical, if TRUE numeric totals are included. |
pct_type |
Controls the kind of percentage values returned. One of "row" or "cell." Column percents are not supported. |
format |
one of "long" or "wide" |
zscore |
defaults to 1.96, consistent with a 95% confidence interval |
unwt_n |
logical, if TRUE it adds a column with unweighted frequency values |
Options include row or cell percentages. The tibble can be in long or wide format. The margin of error includes the design effect of the weights.
a tibble
1 2 | moe_crosstab(df = illinois, x = voter, y = raceethnic, weight = weight)
moe_crosstab(df = illinois, x = voter, y = raceethnic, weight = weight, n = FALSE)
|
# A tibble: 8 x 5
voter raceethnic pct moe n
<fct> <fct> <dbl> <dbl> <dbl>
1 Voted White 76.4 0.607 56230937.
2 Voted Black 15.5 0.517 56230937.
3 Voted Hispanic 5.48 0.325 56230937.
4 Voted Other 2.61 0.228 56230937.
5 Not voted White 74.1 0.838 32070164.
6 Not voted Black 10.8 0.594 32070164.
7 Not voted Hispanic 10.3 0.581 32070164.
8 Not voted Other 4.83 0.410 32070164.
# A tibble: 8 x 4
voter raceethnic pct moe
<fct> <fct> <dbl> <dbl>
1 Voted White 76.4 0.607
2 Voted Black 15.5 0.517
3 Voted Hispanic 5.48 0.325
4 Voted Other 2.61 0.228
5 Not voted White 74.1 0.838
6 Not voted Black 10.8 0.594
7 Not voted Hispanic 10.3 0.581
8 Not voted Other 4.83 0.410
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.