Add p-values
Usage
# S3 method for class 'tbl_continuous'
add_p(
x,
test = NULL,
pvalue_fun = label_style_pvalue(digits = 1),
include = everything(),
test.args = NULL,
group = NULL,
...
)
Arguments
- x
(
tbl_continuous
)
table created withtbl_continuous()
- test
List of formulas specifying statistical tests to perform for each variable. Default is two-way ANOVA when
by=
is notNULL
, and has the same defaults asadd_p.tbl_continuous()
whenby = NULL
. See tests for details, more tests, and instruction for implementing a custom test.- pvalue_fun
(
function
)
Function to round and format p-values. Default islabel_style_pvalue()
. The function must have a numeric vector input, and return a string that is the rounded/formatted p-value (e.g.pvalue_fun = label_style_pvalue(digits = 2)
).- include
(
tidy-select
)
Variables to include in output. Default iseverything()
.- test.args
(
formula-list-selector
)
Containing additional arguments to pass to tests that accept arguments. For example, add an argument for all t-tests, usetest.args = all_tests("t.test") ~ list(var.equal = TRUE)
.- group
(
tidy-select
)
Variable name of an ID or grouping variable. The column can be used to calculate p-values with correlated data. Default isNULL
. See tests for methods that utilize thegroup
argument.- ...
These dots are for future extensions and must be empty.
Examples
trial |>
tbl_continuous(variable = age, by = trt, include = grade) |>
add_p()
Characteristic
Drug A
N = 981
Drug B
N = 1021
p-value2
1 Age: Median (Q1, Q3)
2 Two-way ANOVA