make_chisq_test_table: Create a one-row summary table for a chi-square test

View source: R/make_chisq_test_table.R

make_chisq_test_tableR Documentation

Create a one-row summary table for a chi-square test

Description

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.

Usage

make_chisq_test_table(
  chisq_object,
  test_type = c("independence", "goodness-of-fit", "homogeneity"),
  digits = 3
)

Arguments

chisq_object

An object or list of objects of class "htest" produced by stats::chisq.test().

test_type

Character string specifying the type of chi-square test. One of "goodness-of-fit", "independence", or "homogeneity". for multiple object, if separate test_type are not provided than given test type will be uesd for all chi square test./

digits

Integer indicating the number of decimal places to round to.

Details

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).

Value

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

Examples

# 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"
)


scaledescr documentation built on April 11, 2026, 5:07 p.m.