# Chi.square on independence: Association between two variables.
# Create a contingency table.
my_table <- as.table(rbind(c(100, 150, 50), c(120, 90, 40)))
dimnames(my_table) <- list(Gender = c("Male", "Female"),
Response = c("Agree", "Neutral", "Disagree"))
# Perform chi-squared test with post-hoc analysis.
f_chisq_test(my_table)
# Use a different adjustment method.
f_chisq_test(my_table, method = "holm")
# Other forms still work like Goodness-of-Fit: Match to theoretical distribution.
# Observed frequencies of rolling with a die 1 - 6.
observed <- c(2, 2, 10, 20, 15, 11)
# Expected probabilities under a fair die.
expected_probs <- rep(1/6, 6)
# Chi-Square Goodness-of-Fit Test.
f_chisq_test(x = observed, p = expected_probs)
Run the code above in your browser using DataLab