| test.chi | R Documentation |
Applies the Pearson chi-square test or Fisher's exact test to assess association between two categorical variables.
test.chi(
x,
y = NULL,
title = "Chi-square Test",
xlab = NULL,
ylab = "Proportion",
style = c("stacked", "barplot", "mosaic", "pie"),
show_table = TRUE,
help = FALSE,
verbose = TRUE
)
x |
Categorical vector or data frame with two columns (group 1 and group 2). |
y |
Categorical vector (group 2). Required if x is a vector. |
title |
Plot title (string). Default: "Chi-square Test". |
xlab |
X-axis label in the plot (string). Default: NULL (uses variable name). |
ylab |
Y-axis label in the plot (string). Default: "Proportion". |
style |
Plot style generated by the function. |
show_table |
Logical. If TRUE, prints the contingency table to the console. Default: TRUE. |
help |
Logical. If TRUE, displays a detailed explanation of the function. Default: FALSE. |
verbose |
Logical. If TRUE, prints messages about the test and expected frequencies. Default: TRUE. |
Test result and contingency table.
data <- data.frame(
control = c(rep("healthy", 50), rep("sick", 150)),
treatment = c(rep("healthy", 100), rep("sick", 100))
)
test.chi(data)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.