View source: R/pairwise-fisher-test.R
pairwise_fisher_test | R Documentation |
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.
pairwise_fisher_test(x, ref)
x |
numeric 2 x m data.frame, matrix, or table |
ref |
column name of the reference column of the input matrix |
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.
data.frame of results for each test.
# 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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.