get_km {easysurv}R Documentation

Generate Kaplan-Meier estimates

Description

Calculates Kaplan-Meier estimates for survival data and returns summary statistics, plots, and additional outputs.

Usage

get_km(
  data,
  time,
  event,
  group = NULL,
  group_labels = NULL,
  just_km = FALSE,
  ...
)

Arguments

data

A data frame containing the survival data.

time

The name of the column in data containing the time-to-event information.

event

The name of the column in data indicating whether the event of interest occurred.

group

(Optional) The name of the column in data defining the grouping variable. Default is NULL.

group_labels

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

just_km

Logical. If TRUE, only the Kaplan-Meier estimates are returned. Default is FALSE.

...

(Optional) Parameters to pass to ggsurvfit.

Value

A list containing Kaplan-Meier estimates, summary statistics, and plots.

Examples

km_results <- get_km(
  data = easysurv::easy_bc,
  time = "recyrs",
  event = "censrec",
  group = "group",
  risktable_symbols = FALSE
)

km_results

[Package easysurv version 2.0.1 Index]