library(survival)
library(broom)
library(ggplot2)
fit <- survfit(Surv(time, status) ~ trt, data = diabetic)
fit <- survfit0(fit) # connect origin
ggplot(
data = tidy(fit),
mapping = aes(x = time, y = estimate)
) +
geom_step(aes(color = strata)) +
geom_stepconfint(aes(ymin = conf.low, ymax = conf.high, fill = strata), alpha = 0.3) +
coord_cartesian(c(0, 50)) +
scale_x_continuous(expand = c(0.02,0)) +
labs(x = 'Time', y = 'Freedom From Event') +
scale_color_manual(
values = c('#d83641', '#1A45A7'),
name = 'Treatment',
labels = c('None', 'Laser'),
aesthetics = c('colour', 'fill')) +
theme_basic()
Run the code above in your browser using DataLab