library("psych350lab")
data(superman, package = "psych350data")
result <- chi_square_answers(superman, "clark_grp", "tomatometer")
# Filled version
ft <- create_rh_contingency(
var1_name = "Height Group",
var2_name = "Tomatometer",
var1_levels = c("Under 6ft", "6ft+"),
var2_levels = c("Rotten", "Fresh"),
KEY = TRUE,
chi_results = result,
hypothesis_pattern = c("=", "<")
)
ft
# Blank version
ft_blank <- create_rh_contingency(
var1_name = "Height Group",
var2_name = "Tomatometer",
var1_levels = c("Under 6ft", "6ft+"),
var2_levels = c("Rotten", "Fresh"),
KEY = FALSE
)
ft_blankContingency Table for Research Hypothesis
Description
Creates a flextable showing a contingency table with observed counts and comparison operators (>, <, =). Can produce either a filled answer KEY or a blank template for student worksheets.
Usage
create_rh_contingency(
var1_name = "Variable 1",
var2_name = "Variable 2",
var1_levels = c("Level 1", "Level 2"),
var2_levels = c("Level A", "Level B"),
KEY = FALSE,
chi_results = NULL,
hypothesis_pattern = NULL
)
Arguments
var1_name
|
Character. Display name for the row variable. |
var2_name
|
Character. Display name for the column variable. |
var1_levels
|
Character vector. Labels for row levels. |
var2_levels
|
Character vector of length 2. Labels for column levels. |
KEY
|
Logical. If TRUE, show observed counts and comparison operators. If FALSE (default), show blank template.
|
chi_results
|
Output from chi_square_answers(). Required when KEY = TRUE.
|
hypothesis_pattern
|
Character vector of comparison operators (e.g., c(“=”, “<”) or c(“>”, “=”)). Each element corresponds to a row in the table. Required when KEY = TRUE.
|
Value
A flextable::flextable() object.