Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upCumulative event number in risk table #117
Comments
|
Another e-mail from a survminer user First, thank you very much for creating survminer. After having it recommended by a friend, we've used it to create Kaplan-Meiers for a number of pending article submissions and upcoming meeting presentations. We have received feedback from reviewers that they would not only like to see the Risk Table (Number at Risk), but also the Cumulative Number of Events. Not finding a ready solution, we manually calculated, and added the information in an image editor per the reviewers / editor's wishes (please see attached image). Do you have recommendations as how to add such information in a less laborious manner? Do you foresee adding such a table as a future feature for the survminer package? We'd have immediate use for it! |
|
I'm working on this |
|
A first attempt: library(survival)
fit<- survfit(Surv(time, status) ~ sex, data = lung)
library(survminer)
ggsurvplot(fit, data = lung, risk.table = TRUE, cumevents = TRUE,
risk.table.title = "No. at Risk",
cumevents.title = "Cumulative No. of Events",
risk.table.y.text = FALSE,
cumevents.y.text = FALSE,
ggtheme = theme_light()) |
|
Creating easily clean tables:
# Fit survival curves
library(survival)
fit<- survfit(Surv(time, status) ~ sex, data = lung)
# Plotting the survival curves
library(survminer)
ggsurv <- ggsurvplot(fit, data = lung, risk.table = TRUE, cumevents = TRUE,
pval = TRUE,
risk.table.title = "No. at Risk",
cumevents.title = "Cumulative No. of Events",
risk.table.height = 0.15, cumevents.height = 0.15,
risk.table.y.text = FALSE,
cumevents.y.text = FALSE
)
# Customizing tables and print
ggsurv$table <- ggsurv$table + theme_cleantable()
ggsurv$cumevents <- ggsurv$cumevents + theme_cleantable()
# print
ggsurv |



(user request by e-mail)
Would you add number of cumulative event under number at risk in each strata?