survplot: Draw augmented K-M survival curves

Description Usage Arguments Details Value Note See Also Examples

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

1
2
3
4
5
surviplot(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

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.

See Also

nrisk

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
 
surv <- Surv(colon$time / 365, colon$status)

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

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

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

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

aroneklund/surviplot documentation built on May 10, 2019, 1:47 p.m.