Skip to contents

Adjusts the p-values of a table for multiple comparisons with stats::p.adjust() and adds them as a q.value column, with a footnote naming the method.

Usage

add_q(x, method = "fdr", pvalue_fun = NULL)

Arguments

x

(ltsummary)
A table with a p.value column, e.g. from add_p() or tbl_regression().

method

(string)
A method of stats::p.adjust(): "fdr" (the default), "holm", "hochberg", "hommel", "bonferroni", "BH", "BY" or "none".

pvalue_fun

(function)
Function that formats the q-values. Default is the function that formats the p-value column.

Value

The table with a q.value column.

Examples

# Example 1 ----------------------------------
trial |>
  tbl_summary(by = trt, include = c(age, grade, response)) |>
  add_p() |>
  add_q()
# Example 2 ---------------------------------- glm(response ~ age + grade + trt, trial, family = binomial) |> tbl_regression(exponentiate = TRUE) |> add_global_p() |> add_q(method = "bonferroni")