lifecycle::badge("maturing") Calculate and add a p-value
# S3 method for tbl_survfit
add_p(
x,
test = "logrank",
test.args = NULL,
pvalue_fun = style_pvalue,
include = everything(),
quiet = NULL,
...
)
Object of class "tbl_survfit"
string indicating test to use. Must be one of "logrank"
, "tarone"
, "survdiff"
,
"petopeto_gehanwilcoxon"
, "coxph_lrt"
, "coxph_wald"
, "coxph_score".
See details below
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)
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)
).
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()
.
Logical indicating whether to print messages in console. Default is
FALSE
Not used
The most common way to specify test=
is by using a single string indicating
the test name. However, if you need to specify different tests within the same
table, the input in flexible using the list notation common throughout the
gtsummary package. For example, the following code would call the log-rank test,
and a second test of the G-rho family.
... %>%
add_p(test = list(trt ~ "logrank", grade ~ "survdiff"),
test.args = grade ~ list(rho = 0.5))
Example 1
Example 2
Other tbl_survfit tools:
add_n.tbl_survfit()
,
add_nevent.tbl_survfit()
,
modify
,
tbl_merge()
,
tbl_split()
,
tbl_stack()
,
tbl_strata()
,
tbl_survfit()