Problem with Risk table in Kaplan-Meier plot
0
0
Entering edit mode
2.0 years ago

Hi everybody! It is my first time here and I wish to as clear and kind as every user in this forum. I am trying to generate a Kaplan-Meier Plot for Overall Survival using survival and ggplot2 packages, with the data contained in data1. OS variable codifies time variable and Exitus variable codifies the events. The plot is generated correctly but when I used the option risk.table=TRUE, the number of patients at risk at time=0 is missing. I always used this code in order to generate Kaplan-Meier plots and I have never had this kind of problem Any advice will be welcome Next, I share mi data and my code:

    data1 <- data.frame("Subject"=1:46,
"Exitus"=c(0,0,1,1,0,1,0,1,0,0,0,1,0,1,0,0,1,
0,0,0,0,1,0,0,0,0,1,1,0,1,0,1,0,0,
1,0,0,1,0,0,0,1,0,0,0,1),
"OS"=c(40.7,40,44,40,45,38.6,38,37,39,42,37,
40.7,40,22,35,40,20,32.7,34.3,34.6,35.4,
17,37,35,30,31,26,30.7,37,20,31,25,37,
31,33,29.5,30.1,7.9,29.2,29.1,34,35,31,
30,32,7))

library(survival)
library(ggplot2)
library(survminer)

##Global OS
fit_OS<- survfit(Surv(OS, Exitus) ~ 1, data = data1)
ggsurvplot(fit_OS)
KM_OS<-ggsurvplot(fit_OS, title="OS", legend = "bottom",
legend.title = "OS",
risk.table = TRUE,
risk.table.col = "black",
ggtheme = theme_bw(),
tables.height = 0.15,
tables.theme = theme_cleantable(),
tables.y.text = FALSE
)
KM_OS$plot<-KM_OS$plot + xlab("Time (months)")
print(KM_OS)

Kaplan-Meier ggplot2 Survival • 358 views