I am using the tidycmprsk
package along with the tbl_cuminc()
function to create a summary table of cumulative incidence. Currently, values below 10 are displayed with one decimal place, while values above 10 are rounded to the nearest whole number.
How can I modify this so that values greater than 10 are also displayed with one decimal place?
For example, in the example below from the tidycmprsk
website (https://mskcc-epi-bio.github.io/tidycmprsk/), I would like to show 24% as 24.X% (16.X%, 33.X%).
Also, I would like to thank the tidycmprsk
team for developing such a great package!
library(tidycmprsk)
#> Registered S3 method overwritten by 'tidycmprsk':
#> method from
#> global_pvalue_fun.tidycrr gtsummary
cuminc(Surv(ttdeath, death_cr) ~ trt, trial) |>
tbl_cuminc(times = c(12, 24), label_header = "**Month {time}**") |>
gtsummary::as_kable()
Characteristic | Month 12 | Month 24 |
---|---|---|
Chemotherapy Treatment | ||
Drug A | 3.1% (0.82%, 8.0%) | 24% (16%, 33%) |
Drug B | 8.8% (4.3%, 15%) | 32% (23%, 42%) |
Created on 2024-09-24 with reprex v2.1.1
Sure, just use the estimate_fun
argument to change the default fun that formats the estimates.
library(tidycmprsk)
#> Registered S3 method overwritten by 'tidycmprsk':
#> method from
#> global_pvalue_fun.tidycrr gtsummary
cuminc(Surv(ttdeath, death_cr) ~ trt, trial) |>
tbl_cuminc(
times = c(12, 24),
label_header = "**Month {time}**",
estimate_fun = gtsummary::label_style_number(scale = 100, digits = 1)
) |>
gtsummary::as_kable()
Characteristic | Month 12 | Month 24 |
---|---|---|
Chemotherapy Treatment | ||
Drug A | 3.1% (0.8%, 8.0%) | 24.5% (16.5%, 33.4%) |
Drug B | 8.8% (4.3%, 15.3%) | 32.4% (23.5%, 41.5%) |
Created on 2024-09-24 with reprex v2.1.1