Skip to content

Instantly share code, notes, and snippets.

@nutterb
Created March 10, 2015 13:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nutterb/fb19644cc18c4e64d12a to your computer and use it in GitHub Desktop.
Save nutterb/fb19644cc18c4e64d12a to your computer and use it in GitHub Desktop.
Examples using ggSurvGraph
#* You'll have to source in the function code from the gist
#* https://gist.github.com/nutterb/004ade595ec6932a0c29
library(ggplot2)
install.packages("KMsurv")
data(kidney, package="KMsurv")
fit <- survfit(Surv(time, delta) ~ type, data=kidney)
ggSurvGraph(fit)
ggSurvGraph(fit, conf.bar=FALSE)
ggSurvGraph(fit, conf.bar=FALSE,
gg_expr=list(geom_rect(aes(xmin=time, xmax=next.time,
ymin=lower, ymax=upper,
fill=strata),
alpha=.25, linetype=0)))
ggSurvGraph(fit, conf.bar=FALSE,
n.risk=TRUE, n.event=TRUE,
gg_expr=list(geom_rect(aes(xmin=time, xmax=next.time,
ymin=lower, ymax=upper,
fill=strata),
alpha=.25, linetype=0)))
ggSurvGraph(fit, conf.bar=FALSE, times=seq(0, 30, by=6),
n.risk=TRUE, n.event=TRUE,
gg_expr=list(geom_rect(aes(xmin=time, xmax=next.time,
ymin=lower, ymax=upper,
fill=strata),
alpha=.25, linetype=0)))
ggSurvGraph(fit, conf.bar=FALSE, times=seq(0, 30, by=6),
n.risk=TRUE, n.event=TRUE, cum.inc=TRUE,
gg_expr=list(geom_rect(aes(xmin=time, xmax=next.time,
ymin=lower, ymax=upper,
fill=strata),
alpha=.25, linetype=0)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment