|
a |
|
b/man/survplot.Rd |
|
|
1 |
\name{survplot} |
|
|
2 |
\alias{survplot} |
|
|
3 |
\title{ Draw augmented K-M survival curves } |
|
|
4 |
\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.} |
|
|
5 |
\usage{ |
|
|
6 |
survplot(x, data = NULL, subset = NULL, |
|
|
7 |
snames, stitle, |
|
|
8 |
col, lty, lwd, |
|
|
9 |
show.nrisk = TRUE, color.nrisk = TRUE, |
|
|
10 |
hr.pos = 'topright', legend.pos = 'bottomleft', ...) |
|
|
11 |
} |
|
|
12 |
\arguments{ |
|
|
13 |
\item{x}{ A formula, as would be appropriate for \code{\link[survival]{survfit}} and \code{\link[survival]{coxph}}. } |
|
|
14 |
\item{data, subset}{ Arguments passed to \code{\link[survival]{survfit}} and \code{\link[survival]{coxph}}. } |
|
|
15 |
\item{snames}{ Names for each stratum, to be used in the legend. If missing, these are inferred from the data. } |
|
|
16 |
\item{stitle}{ Title for the strata legend. If missing, this is inferred from \code{x}. } |
|
|
17 |
\item{col, lty, lwd}{ Colors, line type, and line width for each stratum (optional). } |
|
|
18 |
\item{show.nrisk}{ Indicate the number-at-risk for each stratum below the plot? } |
|
|
19 |
\item{color.nrisk}{ Color the number-at-risk to match the plot? } |
|
|
20 |
\item{hr.pos}{ Where to put the hazard ratio information, or NA to omit (see \code{\link{legend}}) } |
|
|
21 |
\item{legend.pos}{ Where to put the legend, or NA to omit (see \code{\link{legend}}) } |
|
|
22 |
\item{\dots}{ Further parameters sent to \code{\link[survival]{plot.survfit}}. } |
|
|
23 |
} |
|
|
24 |
\details{ |
|
|
25 |
This function was written and documented by Aron Charles Eklund in his package |
|
|
26 |
survplot version 0.0.7. |
|
|
27 |
|
|
|
28 |
Hazard ratio (and 95\% confidence intervals) and logrank P are calculated and displayed if there are exactly two groups. |
|
|
29 |
|
|
|
30 |
If there is exactly one group (no stratification), the legend is omitted. |
|
|
31 |
} |
|
|
32 |
\value{ If there are exactly two groups, a character vector with the HR and P value is returned invisibly. } |
|
|
33 |
\author{Aron Charles Eklund (survplot version 0.0.7)} |
|
|
34 |
\note{ The lower figure margin is increased if the number-at-risk is displayed. } |
|
|
35 |
\seealso{ \code{\link{nrisk}} } |
|
|
36 |
\examples{ |
|
|
37 |
library(survival) |
|
|
38 |
surv <- Surv(colon$time / 365, colon$status) |
|
|
39 |
|
|
|
40 |
survplot(surv ~ rx, |
|
|
41 |
data = colon, |
|
|
42 |
lty = 1:3, |
|
|
43 |
main = 'Patients stratified by treatment', |
|
|
44 |
xlab = 'Time (Years)') |
|
|
45 |
|
|
|
46 |
survplot(surv ~ colon$sex, |
|
|
47 |
main = 'Patients stratified by sex', |
|
|
48 |
xlab = 'Time (Years)', |
|
|
49 |
snames = c('F', 'M'), |
|
|
50 |
stitle = 'Gender') |
|
|
51 |
|
|
|
52 |
survplot(surv ~ sex, |
|
|
53 |
data = colon, |
|
|
54 |
subset = colon$surg == 1) |
|
|
55 |
|
|
|
56 |
## Example without stratification |
|
|
57 |
survplot(surv ~ 1, data = colon) |
|
|
58 |
|
|
|
59 |
} |
|
|
60 |
\keyword{ survival } |
|
|
61 |
\keyword{ hplot } |