geom_kmticks {ggquickeda} | R Documentation |
Add tick marks to a Kaplan-Meier survival curve
Description
Adds tickmarks at the times when there are censored observations but no events
Usage
geom_kmticks(
mapping = NULL,
data = NULL,
stat = "kmticks",
position = "identity",
show.legend = NA,
inherit.aes = TRUE,
na.rm = TRUE,
...
)
Arguments
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this
layer, 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 |
na.rm |
If |
... |
Other arguments passed on to |
Aesthetics
geom_kmticks
understands the following aesthetics (required aesthetics
are in bold):
-
x
The survival/censoring times. This is automatically mapped bystat_kmticks()
-
y
The survival probability estimates. This is automatically mapped bystat_kmticks()
smallest level in sort order is assumed to be 0, with a warning -
alpha
-
color
-
linetype
-
size
See Also
The default stat for this geom is stat_kmticks see that documentation for more options to control the underlying statistical transformation.
Examples
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), group = factor(sex))) +
geom_km() + geom_kmticks(col="black")