af_tab: One and two-way tables for categorical questions

Description Arguments Details Value Examples

View source: R/af_tab.R

Description

Easily produced one and two-way tables for categorical questions accompanied by a barplot

Arguments

afro

An afrobarometer dataframe

question

A string specifying the dependent varirable to examine

question2

A string specifying the independent variable to examine

miss

A boolean specifying whether or not to include missing/don't know/refused responses (default FALSE)

digits

An integer specifying number of digits to round to (default is 2)

pos

For two variables, specifies the style of the barplot: "stack" or "dodge" (default)

Details

If a cross-tab, also performs a chi-square test

Value

A table object of the proportion table or cross-tab

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# For question 5: Produce a table of percentages, a table of raw numbers,
# and a barplot of responses, dropping missing/don't know/refused responses
afro %>% af_tab("q5")

# For question 5: Produces a table of percentages, a table of raw numbers,
# and a barplot of responses, including missing/don't know/refused responses
# afro %>% af_tab("q5", miss=T)

# For questions 5 & 7: Produces a cross-tab table of proportions,
# a table of raw numbers, and a side-by-side barplot of responses,
# dropping missing/don't know/refused responses
afro %>% af_tab("q5", "q7")

# For questions 5 & 7: Produces a cross-tab table of proportions,
# a table of raw numbers, and a stacked barplot of responses,
# dropping missing/don't know/refused responses
afro %>% af_tab("q5", "q7", pos="stack")

mdaku/afrobar documentation built on Nov. 4, 2019, 6:23 p.m.