ggSurvival: Kaplan Meier plots with the ggplot package

Description Usage Arguments Details Author(s) Examples

Description

ggSurvplot creates a ggplot object from a 'survfit' object. The resulting plot can be extended using any of ggplot's many tools

Usage

1
2
3
4
ggSurvival(s, CI = FALSE, spot.cens = FALSE, surv.col = 'gg.def',
cens.col = 'red', lty.est = 1, lty.ci = 2, lwd.est=1, lwd.ci=1,
cens.shape = 3, black.white = TRUE, xlab = 'Time', ylab = 'Survival',
 main = '',stratName=NULL, groupNames=NULL, groupNameLevels=NULL)

Arguments

s

A object of class 'survfit'

CI

Logical indicating whether to plot confidence intervals as defined in the survfit object

spot.cens

Logical indicating whether to add tick marks to censor points

surv.col

A vector of colors for the survival curves

cens.col

A color for the censor ticks

lty.est

A vector of line types for the survival curves

lty.ci

A vector of line types for the confidence intervals

lwd.est

A vector of line widths for the survival curves

lwd.ci

A vector of line widths for the confidence intervals

cens.chape

A character string or number indicating what shape the censor indicator should be.

black.white

Logical indicating whether to use theme_bw

xlab,ylab,main

Same as ggplot2 and base

stratName

A character string which overrides the name of the stratification variable (optional for prettyification).

groupNames

A character vector renaming the levels of the stratification variable. These must be in the same order as the original factor levels (optional).

groupNameLevels

A character vector of the stratification variable levels in the order which you want them to appear.

ylimit

a vector giving the limits for plotting the y axis (default to c(0,1)).

Details

The plot is constructed from the survfit object by accessing the internal structure of the fit and plotting a curve for each strata and confidence interval if desired.

Author(s)

Dominic LaRoche (adapted from Edwin Thoen)

Examples

1
2
3
4
5
6
7
8
require(survival)
require(ggplot2)
data(BDSSRecurrenceExample)
dat <- BDSSRecurrenceExample
dat$Rec<-ifelse(dat$Recur=="recurred",1,0)
sv<-Surv(dat$time,dat$Rec)
sv.fit<-survfit(sv~treated,data=dat)
ggSurvival(sv.fit,stratName="Treatment")+theme(legend.position="bottom")

rocrat/BDSS documentation built on May 20, 2019, 5:39 p.m.