Chi-Square Test of Independence

Description

Performs a chi-square test of independence on two categorical variables, returning observed and expected frequencies, proportions, and descriptive counts. All numeric values stored unrounded.

Usage

chi_square_answers(data, var1, var2)

Arguments

data A data frame or tibble.
var1 Character string. Name of the first categorical variable (rows).
var2 Character string. Name of the second categorical variable (columns).

Value

A list with elements (all numeric values unrounded).

Examples

library("psych350lab")

# Using Superman data: test relationship between clark_grp and tomatometer
result <- chi_square_answers(psych350data::superman, "clark_grp", "tomatometer")

# Access the chi-square statistic and p-value
result$ChiSquare