# Load required packages and data
library(dplyr)
data(survey_data)
# Test whether gender split is 50/50
survey_data %>%
binomial_test(gender, p = 0.50)
# Test whether East region proportion is 50%
survey_data %>%
binomial_test(region, p = 0.50)
# Multiple variables at once
survey_data %>%
binomial_test(gender, region, p = 0.50)
# Weighted analysis
survey_data %>%
binomial_test(gender, p = 0.50, weights = sampling_weight)
# Grouped analysis (separate test per region)
survey_data %>%
group_by(region) %>%
binomial_test(gender, p = 0.50)
Run the code above in your browser using DataLab