add_highlight: Highlight a specific strata

View source: R/add_highlight.R

add_highlightR Documentation

Highlight a specific strata

Description

S3 method for highlighting a specific strata by lowering the opacity of all other strata.

Usage

add_highlight(gg, ...)

## S3 method for class 'ggsurvfit'
add_highlight(gg = NULL, strata = NULL, bg_alpha = 0.2, ...)

Arguments

gg

A ggplot created with visR

...

other arguments passed on to the method

strata

String representing the name and value of the strata to be highlighted as shown in the legend.

bg_alpha

A numerical value between 0 and 1 that is used to decrease the opacity off all strata not chosen to be highlighted in strata. The other strata's existing alpha values are multiplied by bg_alpha to decrease their opacity, highlighting the target strata. This works on both colour and fill properties, as for example present after applying visR::add_CI().

Value

The input ggsurvfit object with adjusted alpha values

Examples


adtte %>%
  visR::estimate_KM(strata = "SEX") %>%
  visR::visr() %>%
  visR::add_CI(alpha = 0.4) %>%
  visR::add_highlight(strata = "M", bg_alpha = 0.2)

strata <- c("Placebo", "Xanomeline Low Dose")

adtte %>%
  visR::estimate_KM(strata = "TRTP") %>%
  visR::visr() %>%
  visR::add_CI(alpha = 0.4) %>%
  visR::add_highlight(strata = strata, bg_alpha = 0.2)


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