survplot: Draw augmented K-M survival curves

View source: R/survplot.R

survplotR Documentation

Draw augmented K-M survival curves

Description

Plot Kaplan-Meier survival curves, automatically generate a key for each strata, and calculate and display hazard ratio if there are exactly two strata. Optionally, indicate the number-at-risk below the main plot.

Usage

survplot(x, data = NULL, subset = NULL, 
         snames, stitle, 
         col, lty, lwd,
         show.nrisk = TRUE, color.nrisk = TRUE,
         hr.pos = 'topright', legend.pos = 'bottomleft', ...)

Arguments

x

A formula, as would be appropriate for survfit and coxph.

data, subset

Arguments passed to survfit and coxph.

snames

Names for each stratum, to be used in the legend. If missing, these are inferred from the data.

stitle

Title for the strata legend. If missing, this is inferred from x.

col, lty, lwd

Colors, line type, and line width for each stratum (optional).

show.nrisk

Indicate the number-at-risk for each stratum below the plot?

color.nrisk

Color the number-at-risk to match the plot?

hr.pos

Where to put the hazard ratio information, or NA to omit (see legend)

legend.pos

Where to put the legend, or NA to omit (see legend)

...

Further parameters sent to plot.survfit.

Details

This function was written and documented by Aron Charles Eklund in his package survplot version 0.0.7.

Hazard ratio (and 95% confidence intervals) and logrank P are calculated and displayed if there are exactly two groups.

If there is exactly one group (no stratification), the legend is omitted.

Value

If there are exactly two groups, a character vector with the HR and P value is returned invisibly.

Note

The lower figure margin is increased if the number-at-risk is displayed.

Author(s)

Aron Charles Eklund (survplot version 0.0.7)

See Also

nrisk

Examples

 
library(survival)
surv <- Surv(colon$time / 365, colon$status)

survplot(surv ~ rx,
  data = colon,
  lty = 1:3, 
  main = 'Patients stratified by treatment', 
  xlab = 'Time (Years)')

survplot(surv ~ colon$sex, 
  main = 'Patients stratified by sex', 
  xlab = 'Time (Years)',
  snames = c('F', 'M'),
  stitle = 'Gender')

survplot(surv ~ sex, 
  data = colon, 
  subset = colon$surg == 1)

## Example without stratification
survplot(surv ~ 1, data = colon)
  

MalgorzataOles/BloodCancerMultiOmics2017 documentation built on March 29, 2024, 2:29 p.m.