The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

Plotting with survival package

This document explains Survival Curves related plotting using {ggplot2} and {ggfortify}.

Plotting with survival package

{ggfortify} let {ggplot2} know how to draw survival curves. After loading {ggfortify}, you can use ggplot2::autoplot function for survfit objects.

library(ggfortify)
library(survival)
fit <- survfit(Surv(time, status) ~ sex, data = lung)
autoplot(fit)

plot of chunk unnamed-chunk-1

There are some options to change survival curve output. Use help(autoplot.survfit) (or help(autoplot.*) for any other objects) to check available options.

autoplot(fit, surv.linetype = 'dashed', conf.int = FALSE,
         censor.shape = '*', censor.size = 5, facets = TRUE, ncol = 2)

plot of chunk unnamed-chunk-2

autoplot(survfit(Surv(time, status) ~ 1, data = lung), surv.colour = 'orange', censor.colour = 'red')

plot of chunk unnamed-chunk-2

autoplot(survfit(Surv(time, status) ~ sex, data = lung), fun = 'event')

plot of chunk unnamed-chunk-2

d.coxph <- survfit(coxph(Surv(time, status) ~ sex, data = lung))
autoplot(d.coxph, surv.linetype = 'dashed', surv.colour = 'blue',
         conf.int.fill = 'dodgerblue3', conf.int.alpha = 0.5, censor = FALSE)

plot of chunk unnamed-chunk-2

Also, you can use autoplot for survival::aareg instance.

autoplot(aareg(Surv(time, status) ~ age + sex + ph.ecog, data = lung))

plot of chunk unnamed-chunk-3

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.