add_quantiles: Add quantile indicators to visR plot

View source: R/add_quantiles.R

add_quantilesR Documentation

Add quantile indicators to visR plot

Description

Method to add quantile lines to a plot.

Usage

add_quantiles(gg, ...)

## S3 method for class 'ggsurvfit'
add_quantiles(
  gg,
  quantiles = 0.5,
  linetype = "dashed",
  linecolour = "grey50",
  alpha = 1,
  ...
)

Arguments

gg

A ggplot created with visR

...

other arguments passed on to the method to modify geom_line

quantiles

vector of quantiles to be displayed on the probability scale, default: 0.5

linetype

string indicating the linetype as described in the aesthetics of ggplot2 geom_line, default: dashed (also supports "mixed" -> horizontal lines are solid, vertical ones are dashed)

linecolour

string indicating the linetype as described in the aesthetics of ggplot2 geom_line, default: grey, (also supports "strata" -> horizontal lines are grey50, vertical ones are the same colour as the respective strata)

alpha

numeric value between 0 and 1 as described in the aesthetics of ggplot2 geom_line, default: 1

Value

Lines indicating the quantiles overlayed on a visR ggplot

Examples


library(visR)

adtte %>%
  estimate_KM("SEX") %>%
  visr() %>%
  add_quantiles()

adtte %>%
  estimate_KM("SEX") %>%
  visr() %>%
  add_quantiles(quantiles = c(0.25, 0.50))

adtte %>%
  estimate_KM("SEX") %>%
  visr() %>%
  add_quantiles(
    quantiles = c(0.25, 0.50),
    linetype = "solid",
    linecolour = "grey"
  )

adtte %>%
  estimate_KM("SEX") %>%
  visr() %>%
  add_quantiles(
    quantiles = c(0.25, 0.50),
    linetype = "mixed",
    linecolour = "strata"
  )


visR documentation built on May 29, 2024, 11:50 a.m.