# Load required packages and data
library(dplyr)
data(survey_data)
# Basic crosstab
survey_data %>% crosstab(gender, region)
# With weights and all percentages
survey_data %>% crosstab(gender, education,
weights = sampling_weight,
percentages = "all")
# Grouped analysis
survey_data %>%
group_by(employment) %>%
crosstab(gender, region, weights = sampling_weight)
# Column percentages only
survey_data %>% crosstab(education, employment, percentages = "col")
Run the code above in your browser using DataLab