Skip to contents

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()).

Usage

fisher.simulate.p(data, variable, by, ...)

Arguments

data

A data set.

variable

Name of the variable to test.

by

Name of the by variable.

...

Unused.

Examples

library(gtsummary)
trial |>
  tbl_summary(include = grade, by = trt) |>
  add_p(test = all_categorical() ~ "fisher.simulate.p")
Characteristic Drug A
N = 98
1
Drug B
N = 102
1
p-value2
Grade

>0.9
    I 35 (36%) 33 (32%)
    II 32 (33%) 36 (35%)
    III 31 (32%) 33 (32%)
1 n (%)
2 Fisher’s Exact Test for Count Data with simulated p-value (based on 2000 replicates)