Add p-values
# 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,
...
)
(tbl_continuous
)
table created with tbl_continuous()
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.
(function
)
Function to round and format p-values. Default is label_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)
).
(tidy-select
)
Variables to include in output. Default is everything()
.
(formula-list-selector
)
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)
.
(tidy-select
)
Variable name 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.
These dots are for future extensions and must be empty.
'tbl_continuous' object
# Example 1 ----------------------------------
trial |>
tbl_continuous(variable = age, by = trt, include = grade) |>
add_p(pvalue_fun = label_style_pvalue(digits = 2))
Characteristic
Drug A
N = 981
Drug B
N = 1021
p-value2
1 Age: Median (Q1, Q3)
2 Two-way ANOVA
# Example 2 ----------------------------------
trial |>
tbl_continuous(variable = age, include = grade) |>
add_p(test = everything() ~ "kruskal.test")
Characteristic
N = 2001
p-value2
1 Age: Median (Q1, Q3)
2 Kruskal-Wallis rank sum test