# Load required packages and data
library(dplyr)
data(survey_data)
# Basic chi-squared test for independence
survey_data %>% chi_square(gender, region)
# With weights
survey_data %>% chi_square(gender, education, weights = sampling_weight)
# Grouped analysis
survey_data %>%
group_by(region) %>%
chi_square(gender, employment)
# With continuity correction
survey_data %>% chi_square(gender, region, correct = TRUE)
# --- Three-layer output ---
result <- chi_square(survey_data, gender, education)
result # compact one-line overview
summary(result) # full detailed output with all sections
summary(result, cross_tabulation = FALSE) # hide cross-tabulation
Run the code above in your browser using DataLab