| 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"),
colors = NULL,
show_table = TRUE,
help = FALSE,
verbose = TRUE
)
x |
Categorical vector or data frame with two columns |
y |
Categorical vector (group 2). Required if |
title |
Plot title (string). Default: |
xlab |
X-axis label in the plot (string). Default: |
ylab |
Y-axis label in the plot (string). Default: |
style |
Plot style generated by the function. |
colors |
Character. Optional plot colors. |
show_table |
Logical. If TRUE, prints the contingency table to the console.
Default: |
help |
Logical. If |
verbose |
Logical. If |
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.