View source: R/make_chisq_test_table.R
| make_chisq_test_table | R Documentation |
This function formats the result of a pre-computed chisq.test()
into a single-row data frame. It supports goodness-of-fit,
independence, and homogeneity chi-square tests and includes an appropriate
effect size with a qualitative interpretation.
make_chisq_test_table(
chisq_object,
test_type = c("independence", "goodness-of-fit", "homogeneity"),
digits = 3
)
chisq_object |
An object or list of objects of class |
test_type |
Character string specifying the type of chi-square test.
One of |
digits |
Integer indicating the number of decimal places to round to. |
The function does not perform the chi-square test itself and does not
introduce new statistical methods. All test statistics are extracted
directly from the supplied chisq.test() object.
For goodness-of-fit tests, Cohen’s w is reported. For tests of independence and homogeneity, Cramér’s V is reported. Effect size interpretations follow conventional benchmarks (0.10 = small, 0.30 = medium, 0.50 = large).
A single-row data frame with the following columns:
test: Type of chi-square test
chi_square: Chi-square statistic
df: Degrees of freedom
p_value: p-value
N: Total sample size
effect_size: Effect size (Cohen’s w or Cramér’s V)
effect_type: Type of effect size reported
effect_interpretation: Qualitative interpretation of effect size
# Goodness-of-fit example
observed <- c(40, 30, 50)
chisq_gof <- chisq.test(observed)
make_chisq_test_table(
chisq_object = chisq_gof,
test_type = "goodness-of-fit"
)
# Independence test example
tbl <- matrix(c(20, 30, 10, 40), nrow = 2)
chisq_ind <- chisq.test(tbl)
make_chisq_test_table(
chisq_object = chisq_ind,
test_type = "independence"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.