plotSurvival: Plot survival or cumulative incidence results

View source: R/plotSurvival.R

plotSurvivalR Documentation

Plot survival or cumulative incidence results

Description

Plot the time-specific estimates returned by estimateSingleEventSurvival() or estimateCompetingRiskSurvival(). Single-event results are plotted as survival probabilities by default and can be displayed as cumulative failure with cumulativeFailure = TRUE. Competing-risk results are cumulative incidence estimates and therefore require cumulativeFailure = TRUE.

Usage

plotSurvival(
  result,
  ribbon = TRUE,
  facet = NULL,
  colour = NULL,
  cumulativeFailure = FALSE,
  riskTable = FALSE,
  riskInterval = 30,
  logLog = FALSE,
  timeScale = "days",
  type = NULL,
  style = NULL
)

Arguments

result

Survival results. A summarised_result or survival_result is accepted.

ribbon

If TRUE, add a ribbon using the confidence interval columns.

facet

Variables to use for facets.

colour

Variables to use for colours.

cumulativeFailure

Whether to plot the cumulative failure probability instead of the survival probability.

riskTable

Whether to print risk table below the plot.

riskInterval

Interval of time to print risk table below the plot. This should be compatible with the eventGap used when estimating the result.

logLog

If TRUE, the survival probabilities are transformed using the log-log formula.

timeScale

The scale of time in the x-axis. Can be "days", "months", or "years".

type

Character string specifying the desired plot type. See visOmopResults::scatterPlot() for supported types. If type = NULL, the default backend plot type is used.

style

A character string defining the visual theme to apply to the plot. You can set this to NULL to apply the standard ggplot2 default style, or provide a name for one of the package's pre-defined styles. Refer to the plotStyle() function for all available style pre-defined themes. For further customization, you can always modify the returned ggplot object directly.

Details

facet and colour should refer to columns available after converting the result with asSurvivalResult(), for example target_cohort, outcome, competing_outcome, variable, or strata columns such as sex.

Value

A plot of survival probabilities or cumulative incidence probabilities over time.

Examples


cdm <- mockMGUS2cdm()
surv <- estimateSingleEventSurvival(cdm,
                                    targetCohortTable = "mgus_diagnosis",
                                    outcomeCohortTable = "death_cohort")
plotSurvival(surv)



CohortSurvival documentation built on Oct. 21, 2026, 5:09 p.m.