Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

pvalue_fun in add_pvalue not working #220

Closed
fedenichetti opened this issue Jul 12, 2024 · 2 comments
Closed

pvalue_fun in add_pvalue not working #220

fedenichetti opened this issue Jul 12, 2024 · 2 comments

Comments

@fedenichetti
Copy link

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
Copy link
Collaborator

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
Copy link
Author

Many thanks and sorry for the inappropriate post. Best,

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants