See gtsummary::tests for more details on how defining custom tests.
fisher.simulate.p() implements Fisher test with computation of p-values by
Monte Carlo simulation in larger than 2×2 tables (see
stats::fisher.test()).
Examples
library(gtsummary)
trial |>
tbl_summary(include = grade, by = trt) |>
add_p(test = all_categorical() ~ "fisher.simulate.p")
Characteristic
Drug A
N = 981
Drug B
N = 1021
p-value2
1 n (%)
2 Fisher’s Exact Test for Count Data with simulated p-value
(based on 2000 replicates)