Skip to contents

Returns a easysurv-themed Kaplan-Meier (KM) plot and related KM info.

Usage

quick_KM(
  data,
  time,
  event,
  strata,
  strata_labels = NULL,
  title = NULL,
  subtitle = NULL,
  add_time_0 = TRUE,
  add_interactive_plot = FALSE,
  font.family = "Roboto Condensed",
  ...
)

Arguments

data

A tibble or data frame containing the survival data with columns for time, event and strata.

time

The name of the time variable in data

event

The name of the event variable in data

strata

The name of the strata variable in data

strata_labels

Optional. A character vector containing the names of the strata (default is NULL). Provide in a consistent order with levels(as.factor(data$strata)).

title

Optional. A title for the KM plot. Default is NULL

subtitle

Optional. A subtitle for the KM plot. Default is NULL

add_time_0

Optional. Uses survival::survfit0 to add the point for a starting time (time 0) to a survfit object's elements. This is useful for plotting. Default is TRUE.

add_interactive_plot

Optional. Whether to include a plotly output of the KM plot. Default is FALSE.

font.family

The name of the font for the KM plot. Default is "Roboto Condensed".

...

Ellipses to pass further arguments to plot_KM.

Value

An object of class quick_KM with components:

KM_all

survfit model output based on survival::survfit(survival::Surv(time, event) ~ as.factor(strata)

KM_indiv

survfit model output based on survival::survfit(survival::Surv(time, event) ~ 1 for each strata

KM_stepped

A table summarizing KM survival over time, presented in a 'stepped' manner to support plotting in Excel.

KM_plot

A KM plot in the easysurv theme.

KM_summary

Summary information for each strata. Includes sample sizes, number of events, restricted mean survival, median, and confidence intervals

Examples

if (FALSE) {
# Load required packages
library(survival)

input_data <- survival::lung

surv_data <- tibble(
  time = input_data$time,
  event = input_data$status - 1,
  strata = as.factor(input_data$sex)
)

KM_check <- quick_KM(
  data = surv_data,
  time = "time",
  event = "event",
  strata = "strata"
)
}