pairwise_fisher_test: Perform pairwise fisher.tests on an input matrix

View source: R/pairwise-fisher-test.R

pairwise_fisher_testR Documentation

Perform pairwise fisher.tests on an input matrix

Description

This function will perform a fisher.test() for all columns relative to the given reference column of the input 2 x m matrix and return a data.frame of the results.

Usage

pairwise_fisher_test(x, ref)

Arguments

x

numeric 2 x m data.frame, matrix, or table

ref

column name of the reference column of the input matrix

Details

The function performs a fisher test for each test column relative to the reference column of the input matrix. The input matrix must be a 2 x m matrix. It is the user's responsibility to ensure the levels of the rows align with the desired odds ratio calculation. e.g. R will calculate the odds ratio as (x[1, "test_col"] / x[2, "test_col"]) / (x[1, "ref_col"] / x[2, "ref_col"]). It is the user's responsibility to make sure x[1, ] and x[2, ] are in the desired order.

Value

data.frame of results for each test.

Examples

# From chisq.test docs:
M <- as.table(rbind(c(762, 327, 468), c(484, 239, 477)))
dimnames(M) <- list(
  gender = c("F", "M"),
  party = c("Democrat", "Independent", "Republican")
)
pairwise_fisher_test(M, ref = "Independent")

jcalendo/coriell documentation built on March 5, 2025, 5:42 a.m.