stat_kmticks | R Documentation |
Adds tick marks to a Kaplan Meier Estimate of Survival
stat_kmticks(
mapping = NULL,
data = NULL,
geom = "kmticks",
position = "identity",
show.legend = NA,
inherit.aes = TRUE,
trans,
...
)
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
geom |
The geometric object to use to display the data, either as a
|
position |
Position adjustment, either as a string naming the adjustment
(e.g. |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
trans |
Transformation to apply to the survival probabilities. Defaults to "identity". Other options include "event", "cumhaz", "cloglog", or define your own using trans_new. |
... |
Other arguments passed to survfit.formula |
This stat is for computing the tick marks for a Kaplan-Meier survival estimate for
right-censored data. The tick marks will appear at each censoring time which is also
not a death time, which is the default for plot.survfit.
It requires the aesthetic mapping x
for the
observation times and status
which indicates the event status,
normally 0=alive, 1=dead. Other choices are TRUE/FALSE (TRUE = death) or 1/2
(2=death).
a data.frame with additional columns:
x |
x in data |
y |
Kaplan-Meier Survival Estimate at x |
stat_kmticks
understands the following aesthetics (required aesthetics
are in bold):
time
The survival times
status
The censoring indicator, see Surv for more information.
alpha
color
linetype
size
stat_km
;
stat_kmband
library(ggplot2)
sex <- rbinom(250, 1, .5)
df <- data.frame(time = exp(rnorm(250, mean = sex)), status = rbinom(250, 1, .75), sex = sex)
ggplot(df, aes(time = time, status = status, color = factor(sex))) +
stat_km() + stat_kmticks()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.