APA 7th-Style Chi-Square Crosstabulation Table

Description

Creates an APA 7th-formatted crosstabulation table with counts, percentages, and chi-square results in footer. Works with both 2x2 tables and tables with 3+ row levels.

Usage

create_apa_chi_crosstabs_table(
  chi_results_list = NULL,
  var1_name = "Variable 1",
  var2_name = "Variable 2",
  var1_labels = NULL,
  var2_labels = c("Group 1", "Group 2"),
  KEY = TRUE,
  include_percentages = TRUE,
  table_title = NULL,
  table_number = NULL
)

Arguments

chi_results_list Output from chi_square_answers() (for 2x2 tables) or chi_square_kgroup_answers() (for 3+ row levels), or NULL for blank table.
var1_name Character. Display name for the row variable.
var2_name Character. Display name for the column variable.
var1_labels Character vector or NULL. Labels for row levels. If NULL and KEY = TRUE, labels are extracted from chi_results_list.
var2_labels Character vector of length 2. Labels for column levels.
KEY Logical. If TRUE (default), fill with values; if FALSE, blank.
include_percentages Logical. If TRUE (default), include row percentages alongside counts (e.g., "15 (62.5%)").
table_title Character or NULL. Optional table caption (italicized).
table_number Integer or NULL. Optional table number (bold).

Value

A flextable::flextable() object.

See Also

chi_square_answers(), chi_square_kgroup_answers()