add_pvalue {ggsurvfit} | R Documentation |
Add p-value
Description
-
add_pvalue("caption")
: Add a p-value to the figure viaggplot2::labs(caption=)
-
add_pvalue("annotation")
: Add a p-value text annotation viaggplot2::annotation("text")
P-values are calculated with survival::survdiff()
or tidycmprsk::glance()
.
Examples of custom placement located in the help file for survfit_p()
.
When a competing risks figure includes multiple outcomes, only the p-value comparing stratum for the first outcome can be placed.
Usage
add_pvalue(
location = c("caption", "annotation"),
caption = "{p.value}",
prepend_p = TRUE,
pvalue_fun = format_p,
rho = 0,
...
)
Arguments
location |
string indicating where to place p-value. Must be one of
|
caption |
string to be placed as the caption/annotation. String will
be processed with |
prepend_p |
prepend |
pvalue_fun |
function to round and style p-value with |
rho |
argument passed to |
... |
arguments passed to |
Value
a ggplot2 figure
See Also
survfit_p()
Examples
survfit2(Surv(time, status) ~ surg, df_colon) %>%
ggsurvfit() +
add_pvalue(caption = "Log-rank {p.value}") +
scale_ggsurvfit()
survfit2(Surv(time, status) ~ surg, df_colon) %>%
ggsurvfit() +
add_pvalue("annotation", size = 5) +
scale_ggsurvfit()