Description Usage Arguments Details Value Author(s) Examples
Plots survival functions by discrete categories (such as genotype).
1 2 3 4 5 6 7 8 9 10 11 12 | ## S3 method for class 'character'
kmplot(object, x, data, ylab, xlab,
ylim, xlim, col, lty,
legend.location = "topright", legend.cex = 1,
legend.median = FALSE, digits = 1,
atrisk = FALSE, ...)
## S3 method for class 'Surv'
kmplot(object, x, data, ylab, xlab,
ylim, xlim, col, lty,
legend.location = "topright", legend.cex = 1,
legend.median = FALSE, digits = 1,
atrisk = FALSE, ...)
|
object |
The name or values of the survival variable |
x |
The name or values of the discrete category variable |
data |
A data frame containing values |
ylab |
A label for the y axis |
xlab |
A label for the x axis |
ylim |
Range for the y-axis |
xlim |
Range for the x-axis |
col |
A vector of colours |
lty |
A vector of line types |
legend.location |
Location for legend |
legend.cex |
Character expansion (size) for legend |
legend.median |
Whether to calculate and include median survival times in legend |
digits |
Number of digits for legend data |
atrisk |
Logical, whether to display at risk numbers |
... |
Other arguments |
This function calculates Kaplan–Meier estimates of survival functions
and draws an annotated plot. The arguments object
and x
specify the survival data and the levels of a discrete factor, either
directly (as variables of class Surv
and factor
respectively), or as names of variables in the data frame data
.
Several options for annotating the plot are supported, which provide
improvements over the default print.survfit
method. A legend
with the number of subjects in each category is automatically added,
this may be disabled by setting legend.location="none"
. The
legend may be automatically annotated with the median survival times
and 95% confidence limits. Numbers of subjects at risk, at each tick
on the x-axis, may be added.
Returns an invisible null. The plot is generated as a side effect.
Toby Johnson Toby.x.Johnson@gsk.com
1 2 3 4 5 6 7 8 9 10 11 12 | library(survival)
data(aoex1)
aoex1 <- within(aoex1, srvDays <- Surv(SRVDY, SRVCFLCD))
## show two different ways of calling, either:
with(aoex1, kmplot(srvDays, rs123456, xlab = "Days"))
## or:
kmplot("srvDays", "rs123456", data = aoex1, xlab = "Days")
## show additional annotation
kmplot("srvDays", "rs123456", data = aoex1, xlab = "Days",
legend.median = TRUE, atrisk = TRUE)
## show correct behaviour when one level has entirely missing survival data
with(aoex1, kmplot(srvDays, STUDYID, xlab = "Days"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.