geom_survTicks: create the ticks of a survival curve as a layer ready to be...

Description Usage Arguments Details Value Examples

View source: R/geom_survTicks.R

Description

Imports: ggplot2

Usage

1
geom_survTicks(data, mapping, ticks = "segment", ...)

Arguments

data

The data to be displayed in this layer. There are three options:

If NULL, the default, the data is inherited from the plot data as specified in the call to ggplot().

A data.frame, or other object, will override the plot data. All objects will be fortified to produce a data frame. See fortify() for which variables will be created.

A function will be called with a single argument, the plot data. The return value must be a data.frame, and will be used as the layer data. A function can be created from a formula (e.g. ~ head(.x, 10)).

mapping

aes object, created with aes(). Provide x (time) and y (status). Optionally you can provide color and linetype to distinguish conditions. For the status: NA will be irgnored, 1 = dropped out, 2 = dead, any other value = alive.

ticks

character, either "segment" or "point". If specified as "point", additional geom_point options can be specified, such as shape

...

Other arguments passed on to layer(). These are often aesthetics, used to set an aesthetic to a fixed value, like colour = "red" or size = 3. They may also be parameters to the paired geom/stat.

Details

calls the geom_surve function but only uses the ticks, not the lines

Value

a ggplot2 layer object (geom_segment for the ticks) that can directly be added to a ggplot2 object

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
library(ggsurvival)
library(ggplot2)

survtest <- data.frame(
  time = sample(seq(30),50,replace = T),
  status = sample(1:2, 50, replace = T),
  condition = sample(c("wt","ko"), 50, replace = T)
)

ggplot() +
  geom_survLines(survtest, aes(time, status, color=condition))
  geom_survTicks(survtest, aes(time, status, color=condition))

NicolasH2/ggsurvival documentation built on Dec. 17, 2021, 5:24 a.m.