| stat_kmticks {ggquickeda} | R Documentation | 
Adds tick marks to a Kaplan Meier Estimate of Survival
Description
Adds tick marks to a Kaplan Meier Estimate of Survival
Usage
stat_kmticks(
  mapping = NULL,
  data = NULL,
  geom = "kmticks",
  position = "identity",
  show.legend = NA,
  inherit.aes = TRUE,
  trans,
  ...
)
Arguments
| 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 | 
Details
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).
Value
a data.frame with additional columns:
| x | x in data | 
| y | Kaplan-Meier Survival Estimate at x | 
Aesthetics
stat_kmticks understands the following aesthetics (required aesthetics
are in bold):
-  timeThe survival times
-  statusThe censoring indicator, see Surv for more information.
-  alpha
-  color
-  linetype
-  size
See Also
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))) +
 stat_km() + stat_kmticks()