makeKMFig: Make a survival curve figure as a ggplot2 object

Description Usage Arguments Value Examples

View source: R/makeKMFig.R

Description

Make a survival curve figure as a ggplot2 object

Usage

1
makeKMFig(formula, data, timepts = NULL, colors = NULL, ribbon = TRUE)

Arguments

formula

A formula object, which must have a 'Surv' object as the response on the left of the '~' operator and the grouping term (often the treatment) on the right.

data

A data frame in which to interpret the variables named in the formula

timepts

A numeric vector of time points to show on the x-axis

colors

Custom colors for each group line

ribbon

Logical to show a semi-transparent confidence band ribbon

Value

A ggplot2 object of a Kaplan-Meier curve

Examples

1
2
3
4
5
6
7
8
makeKMFig(formula = survival::Surv(stime, scens) ~ treatment, data = mice)

makeKMFig(formula = survival::Surv(stime, scens) ~ treatment, data = mice) +
  ggplot2::labs(y = "OS", color = "Treatment")

makeKMFig(formula = survival::Surv(stime, scens) ~ treatment, data = mice, ribbon = FALSE) +
  ggplot2::scale_color_brewer(palette = "Set1") +
  ggplot2::scale_fill_brewer(palette = "Set1")

jbirstler/survivalFigs documentation built on Jan. 18, 2021, 6:28 p.m.