gtsummary (version 1.3.6)

tbl_survival.survfit: Creates table of survival probabilities

Description

questioning Please use tbl_survfit. Function takes a survfit object as an argument, and provides a formatted summary of the results

Usage

# S3 method for survfit
tbl_survival(
  x,
  times = NULL,
  probs = NULL,
  label = ifelse(is.null(probs), "{time}", "{prob*100}%"),
  level_label = "{level}, N = {n}",
  header_label = NULL,
  header_estimate = NULL,
  failure = FALSE,
  missing = "-",
  estimate_fun = NULL,
  ...
)

Value

A tbl_survival object

level_label argument

The level_label is used to modify the stratum labels. The default is level_label = "{level}, N = {n}". The quantities in the curly brackets evaluate to stratum-specific values. For example, in the trial data set, there is a column called trt with levels 'Drug A' and 'Drug B'. In this example, {level} would evaluate to either 'Drug A' or 'Drug B' depending on the stratum. Other quantities available to print are:

  • {level} level of the stratification variable

  • {level_label} label of level for the stratification variable

  • {n} number of observations, or number within stratum

  • {n.event.tot} total number of events (total across stratum, if applicable)

  • {n.event.strata} total number of events within stratum, if applicable

  • {strata} raw stratum specification from survfit object

Example Output

Example 1

Example 2

See Also

Other tbl_survival tools: inline_text.tbl_survival()

Examples

Run this code
# NOT RUN {
# Example 1 ----------------------------------
library(survival)
fit1 <- survfit(Surv(ttdeath, death) ~ trt, trial)
tbl_strata_ex1 <-
  tbl_survival(
    fit1,
    times = c(12, 24),
    label = "{time} Months"
  )

# Example 2 ----------------------------------
fit2 <- survfit(Surv(ttdeath, death) ~ 1, trial)
tbl_nostrata_ex2 <-
  tbl_survival(
    fit2,
    probs = c(0.1, 0.2),
    header_estimate = "**Months**"
  )
# }

Run the code above in your browser using DataLab