addNrisk: Add number-at-risk annotations to a plot

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/survplot.R

Description

Add number-at-risk (NAR) annotations to an existing survival plot, underneath the X-axis.

Usage

1
2
3
4
addNrisk(x, at = axTicks(1), 
         line = 4, hadj = 0.5, 
         title = "Number at risk", title.adj = 0, 
         labels, hoff = 5, col = 1)

Arguments

x

A list as returned by survfit.

at

Time points at which the NAR values are calculated and placed.

line

Number of lines into the margin to start displaying the NAR.

hadj

Horizontal adjustment for the NAR values.

title

Optional title above the NAR.

title.adj

Text adjustment for the title

labels

Labels for each stratum.

hoff

Horizontal offset for the labels

col

Color for each stratum.

Details

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

Value

Invisibly, a matrix containing the number-at-risk values

Author(s)

Aron Charles Eklund (survplot version 0.0.7)

See Also

See nrisk to retrieve number-at-risk values without plotting them. See also survplot.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
library(survival)
s <- Surv(colon$time / 365, colon$status)

## Need to increase margins a bit
par(mar = c(10,6,2,1))

## no stratification
fit1 <- survfit(s ~ 1)
plot(fit1)
addNrisk(fit1)

## with stratification
fit2 <- survfit(s ~ rx, data = colon)
plot(fit2, xlab = 'Time (years)', ylab = 'Survival')
addNrisk(fit2)

MalgorzataOles/pace documentation built on Nov. 18, 2017, 7:51 a.m.