surv_table: Summary table

surv_tableR Documentation

Summary table

Description

Prints a formatted summary table for survfit objects.

Usage

surv_table(
  object,
  digits = ifelse(percent, 0L, 3L),
  times = pretty(object$time),
  maxtime = FALSE,
  percent = FALSE,
  locf = FALSE,
  median = FALSE,
  ci.median = TRUE,
  ci.type = c("conf.int", "range"),
  digits.median = 0L,
  na.median = "NR",
  fun = c("S", "F"),
  ...
)

Arguments

object

an object of class survfit

digits

number of digits to use in printing numbers

times

vector of times

maxtime

logical; if TRUE, adds the maximum time for which an even occurs; if FALSE, number of events may not sum to total

percent

logical; if TRUE, percentages are shown instead of probabilities

locf

logical; if TRUE, any NA probabilities will be carried forward, e.g., if no events occurred during two consecutive time intervals

median, ci.median

logical; if TRUE, the median (and confidence interval) will be added as a separate column

ci.type

for the median confidence interval, show either the object$conf.int or the full range; see surv_extract

digits.median

for the median, the number of digits past the decimal point to keep

na.median

a string to use in place of "NA" for the median text; default is "NR" for "not reached"

fun

survival estimate transformation, one of "S" or "F" for the usual survival probabilities, S, or 1 - S, respectively

...

additional arguments passed to surv_summary and further to summary.survfit

Value

A matrix (or list of matrices) with formatted summaries for each strata; see summary.survfit

See Also

survfit; print.summary.survfit

Examples

library('survival')
fit0 <- survfit(Surv(time, status == 2) ~ 1, data = cancer)
surv_table(fit0, times = 0:2 * 100)
surv_table(fit0, times = 0:2 * 100, median = TRUE)
surv_table(fit0, times = 0:2 * 100, median = TRUE, ci.type = 'range')

## also works for list of tables
fit1 <- survfit(Surv(time, status == 2) ~ sex, data = cancer)
surv_table(fit1, median = TRUE, digits.median = 2, ci.median = FALSE)
rawr::combine_table(surv_table(fit1, median = TRUE))


raredd/rawr documentation built on April 29, 2024, 10:29 a.m.