pvalue_fun in add_pvalue not working
Closed this issue · 2 comments
fedenichetti commented
I would like to round the log rank p value to 3 decimals, but when running
test %>%
ggsurvfit() +
#add_confidence_interval() +
add_risktable(
theme = # increase font size of risk table title and y-axis label
list(
theme_risktable_default(),
theme(plot.title = element_text(face = "bold"))
)
) +
add_censor_mark(size = 2, alpha = 0.8) +
add_quantile(y_value = 0.5, linetype = "dotted", color = "grey30", linewidth = 0.5) +
scale_ggsurvfit() + #add_confidence_interval() +
scale_color_manual(values = c("#0B3F54","#D14055")) +
add_pvalue(location = "annotation", x = 10, pvalue_fun = ~ style_pvalue(.x, digits = 3))
Error in `update_add_pvalue()`:
! The `add_pvalue(pvalue_fun=)` argument must be a function.
Run `rlang::last_trace()` to see where the error occurred.
How should I solve this?
Thanks!
ddsjoberg commented
Dear @fedenichetti ,
The error message says that add_pvalue(pvalue_fun=)
argument must be a function, and you've passed a formula. There are some tidyverse functions that convert that formula notation to a function, but that does not occur here. Try this:
add_pvalue(pvalue_fun = function(.x) style_pvalue(.x, digits = 3))
FYI GitHub is primarily a space to report bugs and make feature requests. For assistance with the package in the future, it's best to post on stackoverflow.com. When you do post, please include a minimal reproducible example. https://reprex.tidyverse.org/
fedenichetti commented
Many thanks and sorry for the inappropriate post. Best,