followup_time: Report Follow-up Among Censored Obs

View source: R/followup_time.R

followup_timeR Documentation

Report Follow-up Among Censored Obs

Description

Function accepts survival::Surv() object, extracts the follow-up times among the censored observations, and returns the requested summary statistics. Use this function to report follow-up in-line in R Markdown reports.

Usage

followup_time(
  Surv,
  data = NULL,
  pattern = "{median} (IQR {p25}, {p75})",
  style_fun = gtsummary::style_sigfig
)

Arguments

Surv

An object of class "Surv" created with survival::Surv()—not a multi-state endpoint.

data

A data frame

pattern

Statistics pattern to return. Default is "{median} (IQR {p25}, {p75})". User may select the following summary statistics to report, "{median}", "{mean}", "{p25}", "{p75}", "{sd}", "{var}", "{min}", and "{max}". Also available are "{n}" (the number of events) and "{N}" (number of non-missing observations).

style_fun

Function used to style/format the summary statistics. Default is gtsummary::style_sigfig. Argument accepts anonymous function notation, e.g. ~gtsummary::style_sigfig(., digits = 3)

Value

string of summary statistics

Examples

library(survival)

followup_time(Surv(time, status), data = lung)

followup_time(
  Surv(time, status), data = lung,
  pattern = "{median} days",
  style_fun = ~gtsummary::style_sigfig(., digits = 4)
)

followup_time(
  survival::Surv(time, status),
  data = survival::lung,
  pattern = "{n} events with a follow-up time of {median} days (IQR {p25}, {p75})"
)

ddsjoberg/bstfun documentation built on Feb. 2, 2023, 2:39 a.m.