ggsurv: Lisa's Survival Plot

View source: R/ggsurv.R

ggsurvR Documentation

Lisa's Survival Plot

Description

This function creates a survival plot from a survfit object using ggplot2 graphics.

Usage

ggsurv(
  sfit,
  surv.lty = 1,
  surv.size = 1,
  surv.col = NA,
  ci = TRUE,
  ci.lty = 2,
  ci.size = 0.5,
  ci.ribbon = TRUE,
  ci.alpha = 0.2,
  cens = TRUE,
  cens.col = "red",
  cens.size = 2,
  cens.shape = 3,
  groups = NA,
  grlabs = NA,
  grname = NA,
  perc = FALSE,
  xlab = "\nTime",
  ylab = "Survival\n",
  xlim = NA,
  ylim = c(0, 1),
  xby = NA,
  xbrlabs = NA,
  yby = 0.1,
  risktab = FALSE,
  risktab.times = NA,
  risktab.label = "Number at risk",
  risktab.margins = c(0, 0, 0.2, 0.15),
  risktab.events = TRUE,
  main = "",
  plab = NA,
  grid = c(TRUE, TRUE),
  themebw = TRUE,
  citrans = FALSE
)

Arguments

sfit

survfit object (REQUIRED).

surv.lty

Numeric vector for line type of survival lines. Default = 1.

surv.size

Number for size of survival lines. Default = 1.

surv.col

Character vector for color of survival lines. Default = "black".

ci

Logical indicator to plot confidence intervals. Default = TRUE.

ci.lty

Number for line type of CI lines. Default = 2.

ci.size

Number for size of CI lines, Default = 1.

ci.ribbon

Logical indicator to use ribbons instead of lines for CI area. Default = FALSE.

ci.alpha

Number between 0 and 1 for shading (alpha) of CI ribbon. Default = 0.20.

cens

Logical indicator to plot markers for censoring. Default = TRUE.

cens.col

Character for color of censoring symbols. Default = "red".

cens.shape

Number for censoring symbol (pch graphical parameter). Default = 3 (plus sign).

groups

Character vector for groups as listed in dataset. Default = NA (no groups).

grlabs

Character vector for group levels, must be in same order as groups. Default = NA (no groups or use group levels from dataset).

grname

Character label for group legend name. Default = NA (no legend title).

perc

Logical indicator to show y axis as percentages. Default = FALSE.

xlab

Character label for x axis. Default = "Time".

ylab

Character label for y axis. Default = "Survival".

xlim

Numeric vector of length 2 for x axis min and max. Default = NA using 0 to data maximum.

ylim

Numeric vector of length 2 for y axis min and max. Default = c(0,1).

xby

Number for x axis major tick marks. Default = NA (ggplot selected).

yby

Numeric for y axis major tick marks. Default = 0.1.

risktab

Logical indicator to include risk table at bottom of plot. Default = FALSE.

risktab.times

Numeric vector of times for risk table. Default = NA (Includes times for x axis tick marks).

risktab.label

Character label for risk table. Default = "Number at risk".

risktab.margins

Numeric vector for plot margins in format c(top, right, bottom, left) where each value is a proportion of plot dimensions. Adjustments may be needed to accomodate long group names or a large number of groups. Default = c(0.00, 0.00, 0.20, 0.15).

risktab.events

Logical indicator to include number of events (for non-stratified plots only). Default = TRUE.

main

Character label for plot title. Default = " ".

plab

Character for annotation in top right corner (for p-value or other notes). Default = NA (no annotation).

grid

Logical vector of length 2 to plot major gridlines in x and y directions. Default = c(TRUE, TRUE). If one value is provided it will apply to both directions.

themebw

Indicator for use of ggplot2 theme_bw. Default = TRUE.

citrans

Logical indicator whether to apply 1-x transformation to plot cumulative incidence. Default = FALSE.


lisaerein/nicesurv documentation built on Dec. 9, 2024, 12:17 a.m.