mplot3_survfit: 'mplot3': Plot 'survfit' objects

View source: R/mplot3_survfit.R

mplot3_survfitR Documentation

mplot3: Plot survfit objects

Description

Plots survival step functions using mplot3_xy

Usage

mplot3_survfit(
  x,
  lty = 1,
  lwd = 1.5,
  alpha = 1,
  col = NULL,
  plot.median = FALSE,
  group.median = FALSE,
  median.lty = 3,
  median.lwd = 2,
  median.col = theme$fg,
  median.alpha = 0.5,
  censor.mark = TRUE,
  censor.col = NULL,
  censor.alpha = 0.4,
  censor.pch = "I",
  censor.cex = 0.8,
  mark.censored = FALSE,
  nrisk.table = FALSE,
  nrisk.pos = "below",
  nrisk.spacing = 0.9,
  table.font = 1,
  time.at = NULL,
  time.by = NULL,
  xlim = NULL,
  ylim = NULL,
  xlab = "Time",
  ylab = "Survival",
  main = "",
  theme = rtTheme,
  palette = rtPalette,
  plot.error = FALSE,
  error.alpha = 0.33,
  autonames = TRUE,
  group.legend = NULL,
  group.legend.type = c("legend", "mtext"),
  group.names = NULL,
  group.title = NULL,
  group.line = NULL,
  group.side = NULL,
  legend.x = NULL,
  mar = c(2.5, 3, 2, 1),
  oma = NULL,
  par.reset = TRUE,
  pdf.width = 6,
  pdf.height = 6,
  filename = NULL,
  ...
)

Arguments

x

survfit object (output of survival::survfit)

lty

Integer: Line type. See par("lty")

lwd

Float: Line width.

alpha

Float: Alpha for lines.

col

Color, vector: Color(s) to use for survival curves and annotations. If NULL, taken from palette

plot.median

Logical: If TRUE, draw lines at 50 percent median survival.

group.median

Logical: If TRUE, include median survival times with group legend

median.lty

Integer: Median survival line type

median.lwd

Float: Median line width.

median.col

Color for median survival lines

median.alpha

Float, (0, 1): Transparency for median survival lines.

censor.mark

Logical: If TRUE, mark each censored case.

censor.col

Color to mark censored cases if censor.mark = TRUE

censor.alpha

Transparency for censor.col.

censor.pch

Character: Point character for censored marks.

censor.cex

Float: Character expansion factor for censor marks.

mark.censored

Logical: This is an alternative to censor.mark which whill mark censored cases using the same color as the survival curve. It can be harder to distinguish the censoring marks from the curve itself, therefore not preferred.

nrisk.table

Logical: If TRUE, print Number at risk table.

nrisk.pos

Character: "above" or "below": where to place nrisk.table

nrisk.spacing

Float: Determines spacing between nrisk.table rows.

table.font

Integer: 1: regular font, 2: bold.

time.at

Float, vector: x-axis positions to place tickmarks and labels as well as n at risk values if nrisk.table = TRUE

time.by

Float: Divide time by this amount to determine placing of tickmarks

xlim

Float, vector, length 2: x-axis limits

ylim

Float, vector, length 2: y-axis limits

xlab

Character: x-axis label

ylab

Character: y-axis label

main

Character: main title

theme

Character: Run themes() for available themes

palette

Vector of colors, or Character defining a builtin palette - get options with rtpalette()

autonames

Logical: If TRUE, extract grouping variable names and level labels from x and use for legend. It is best to give informative level labels, like female, male instead of 0, 1 when using this.

group.legend

Logical: If TRUE, include group legend

group.names

Character, vector: Group names to use. If NULL, extracted from x

group.title

Character: Group legend title

group.line

Float, vector: Lines to print group legend using mtext

group.side

Integer: Side to print group legend. Default is determined by survival curves, to avoid overlap of legend with curves.

mar

Float, vector, length 4: Margins. See par("mar")

oma

Float, vector, length 4: Outer margins. See par("oma")

par.reset

Logical: If TRUE, reset par to initial values before exit

...

Additional arguments to pass to theme

Author(s)

E.D. Gennatas

Examples

## Not run: 
# Get the lung dataset
data(cancer, package = "survival")
sf1 <- survival::survfit(survival::Surv(time, status) ~ 1, data = lung)
mplot3_survfit(sf1)
sf2 <- survival::survfit(survival::Surv(time, status) ~ sex, data = lung)
mplot3_survfit(sf2)
# with N at risk table
mplot3_survfit(sf2, nrisk.table = TRUE)

## End(Not run)

egenn/rtemis documentation built on May 4, 2024, 7:40 p.m.