survminer icon indicating copy to clipboard operation
survminer copied to clipboard

ggsurvplot cumevents decimal places / digits when using weights

Open MaverickMeerkat opened this issue 3 years ago • 2 comments

I use weights on my survfit function. I want to plot in the risk table also the cumulative events, but unfortunately it produces very long numbers with a lot of decimal digits. Is there anyway to control for the cumevents digits? The problem doesn't happen if I don't use weights.

image

MaverickMeerkat avatar Sep 21 '21 15:09 MaverickMeerkat

How to linstall

install.packages("devtools")
devtools::install_github('ningyile/survminer')

https://github.com/ningyile/survminer

Features

In theutilities.R, the cum.n.event and cum.n.censor was not rounded like other functions(such as n.risk, n.event, etc.). So I just fix the issue of [ggsurvplot cumevents decimal places / digits when using weights](https://github.com/kassambara/survminer/issues/554) by round the cumulative number of event( namely cum.n.event ) and censoring( namely cum.n.censor ) in weighted survival estimates(such as inverse-probability weight, IPW). @MaverickMeerkat

ningyile avatar Nov 02 '22 10:11 ningyile

For now, you can manually edit the table by editing the ggsurvplot object.

ggsurv <- ggsurvplot(fit, data) ggsurv$cumevents$layers[[1]]$data$cum.n.event <-round(ggsurv$cumevents$layers[[1]]$data$cum.n.event)

shengchaohou avatar Feb 21 '24 17:02 shengchaohou