Learn R Programming

guideR (version 0.8.1)

gtsummary_test: Additional tests for gtsummary

Description

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()). svyttest_oneway() is designed to compare means between sub-groups for survey objects. It is based on survey::svyttest() for comparing 2 means, and on svyoneway() for comparing 3 means or more.

Usage

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

svyttest_oneway(data, variable, by, ...)

Arguments

data

A data set.

variable

Name of the variable to test.

by

Name of the by variable.

...

Unused.

Examples

Run this code
if (FALSE) { # rlang::is_installed("gtsummary")
library(gtsummary)
trial |>
  tbl_summary(include = grade, by = trt) |>
  add_p(test = all_categorical() ~ "fisher.simulate.p")
}
if (FALSE) { # rlang::is_installed(c("gtsummary", "srvyr", "survey"))
# \donttest{
iris |>
  srvyr::as_survey() |>
  tbl_svysummary(
    include = Petal.Length,
    by = Species
   ) |>
   add_p(test = all_continuous() ~ svyttest_oneway)
# }
}

Run the code above in your browser using DataLab