add_p.tbl_continuous: P-values for 'tbl_continuous'

View source: R/add_p.R

add_p.tbl_continuousR Documentation

P-values for tbl_continuous

Description

P-values for tbl_continuous

Usage

## S3 method for class 'tbl_continuous'
add_p(
  x,
  test = NULL,
  pvalue_fun = NULL,
  include = everything(),
  test.args = NULL,
  group = NULL,
  ...
)

Arguments

x

Object with class tbl_summary from the tbl_summary function

test

List of formulas specifying statistical tests to perform for each variable. Default is two-way ANOVA when by= is not NULL, and has the same defaults as add_p.tbl_continuous() when by = NULL. See tests for details, more tests, and instruction for implementing a custom test.

pvalue_fun

Function to round and format p-values. Default is style_pvalue. The function must have a numeric vector input (the numeric, exact p-value), and return a string that is the rounded/formatted p-value (e.g. pvalue_fun = function(x) style_pvalue(x, digits = 2) or equivalently, purrr::partial(style_pvalue, digits = 2)).

include

Variables to include in output. Input may be a vector of quoted variable names, unquoted variable names, or tidyselect select helper functions. Default is everything().

test.args

List of formulas containing additional arguments to pass to tests that accept arguments. For example, add an argument for all t-tests, use test.args = all_tests("t.test") ~ list(var.equal = TRUE)

group

Column name (unquoted or quoted) of an ID or grouping variable. The column can be used to calculate p-values with correlated data. Default is NULL. See tests for methods that utilize the group= argument.

...

Not used

See Also

Other tbl_continuous tools: add_overall(), tbl_continuous()

Examples

add_p_continuous_ex1 <-
  tbl_continuous(
    data = trial,
    variable = age,
    by = trt,
    include = grade
  ) %>%
  add_p()

gtsummary documentation built on April 26, 2022, 1:05 a.m.