test_fisher: Fisher's Exact Test

View source: R/Fisher_test.R

test_fisherR Documentation

Fisher's Exact Test

Description

Performs Fisher's Exact Test using two categorical vectors or a data frame with two columns, constructing a contingency table and optionally generating graphical visualizations.

Usage

test_fisher(
  x,
  y = NULL,
  title = "Fisher's Exact Test",
  xlab = NULL,
  ylab = NULL,
  style = c("stacked", "barplot", "mosaic", "pie"),
  colors = NULL,
  show_table = TRUE,
  help = FALSE,
  verbose = TRUE
)

Arguments

x

Categorical vector or data frame with two columns.

y

Categorical vector (required if x_var is a vector).

title

Plot title (string). Default: "Fisher's Exact Test"

xlab

Name of the x-axis in the plot (string). Default: NULL (uses variable name).

ylab

Name of the y-axis in the plot (string). Default: "Proportion".

style

Plot style. Controls the visualization type.

colors

Character. Optional plot colors.

show_table

Logical. If TRUE, prints the contingency table to the console. Default: TRUE.

help

Logical. If TRUE, shows detailed function explanation. Default: FALSE.

verbose

Logical. If TRUE, prints detailed test messages. Default: TRUE.

Value

Invisible object containing the Fisher test result.

Examples

data <- data.frame(control = c(rep("healthy", 1), rep("sick", 5)),
                   treatment = c(rep("healthy", 5), rep("sick", 1)))
test_fisher(data)

autotestR documentation built on Oct. 27, 2026, 1:07 a.m.