Reputation: 864
We noticed a difference between how R (survival
package) and SAS (or survminer
) display KM curves censoring events. When an event occur at the same time as a censoring one the +
mark is not displayed in the graph. The survminer::ggsurvplot
function display the censoring event correctly like SAS.
Am I missing something here? How do I get plot.survfit to display all the censoring 'events'?
library(survival)
library(survminer)
df <- data.frame(time=c(4,6,8,11,15,15,17,18,19),
cens=c(0,0,1, 0, 1, 0, 1, 0, 1))
mod <- survfit(Surv(time, !cens) ~ 1, data=df)
# plotting with the survival package does not show a mark at time = 15
plot(mod, mark=1, mark.time = TRUE, conf.int = FALSE)
# plotting with survminer or SAS display the mark at time 15.
ggsurvplot(mod, data = df, conf.int = FALSE)
Upvotes: 1
Views: 1537
Reputation: 864
found the solution.
plot(mod, mark=1, conf.int = FALSE, mark.time=mod$time[mod$n.censor > 0])
Upvotes: 2