kaplan_meier {junco}R Documentation

Survival time analysis

Description

[Stable]

The analyze function kaplan_meier() creates a layout element to analyze survival time by calculating survival time median, 2 quantiles, each with their confidence intervals, and range (for all, censored, or event patients). The primary analysis variable vars is the time variable and the secondary analysis variable is_event indicates whether or not an event has occurred.

Usage

a_kaplan_meier(
  df,
  .var,
  ...,
  .stats = NULL,
  .formats = NULL,
  .labels = NULL,
  .indent_mods = NULL
)

s_kaplan_meier(df, .var, is_event, control = control_surv_time())

Arguments

df

(data.frame)
data set containing all analysis variables.

.var

(string)
single variable name that is passed by rtables when requested by a statistics function.

...

additional arguments for the lower level functions.

.stats

(character)
statistics to select for the table.

.formats

(named character or list)
formats for the statistics. See Details in analyze_vars for more information on the 'auto' setting.

.labels

(named character)
labels for the statistics (without indent).

.indent_mods

(named integer)
indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.

is_event

(character)
variable name storing Logical values: TRUE if event, FALSE if time to event is censored.

control

(list)
parameters for comparison details, specified by using the helper function tern::control_surv_time(). Some possible parameter options are:

  • conf_level (proportion)
    confidence level of the interval for survival time.

  • conf_type (string)
    confidence interval type. Options are 'plain' (default), 'log', or 'log-log', see more in survival::survfit(). Note option 'none' is not supported.

  • quantiles (numeric)
    vector of length two to specify the quantiles of survival time.

Value

Functions

Note

These functions have been forked from the tern package file survival_time.R. Here we have the additional features:

Examples

library(dplyr)
library(tern)
adtte_f <- tern::tern_ex_adtte |>
  filter(PARAMCD == "OS") |>
  mutate(
    AVAL = tern::day2month(AVAL),
    is_event = CNSR == 0
  )
df <- adtte_f |> filter(ARMCD == "ARM A")
a_kaplan_meier(
  df,
  .var = "AVAL",
  is_event = "is_event"
)

basic_table() |>
  split_cols_by(var = "ARMCD") |>
  add_colcounts() |>
  analyze(
    vars = "AVAL",
    afun = a_kaplan_meier,
    var_labels = "Kaplan-Meier estimate of time to event (months)",
    show_labels = "visible",
    extra_args = list(
      is_event = "is_event",
      control = control_surv_time(conf_level = 0.9, conf_type = "log-log")
    )
  ) |>
  build_table(df = adtte_f)


[Package junco version 0.1.1 Index]