tidy_survfit: Tidy a survfit object

View source: R/tidy_survfit.R

tidy_survfitR Documentation

Tidy a survfit object

Description

The broom package exports a tidier for "survfit" objects. This function adds on top of that and returns more information. The function also utilizes additional information stored when the survfit object is created with survfit2(). It's recommended to always use this function with survfit2().

Usage

tidy_survfit(x, times = NULL, type = c("survival", "risk", "cumhaz"))

Arguments

x

a 'survfit' object created with survfit2()

times

numeric vector of times. Default is NULL, which returns all observed times.

type

type of statistic to report. Available for Kaplan-Meier estimates only. Default is "survival". Must be one of the following:

type transformation
"survival" x
"risk" 1 - x
"cumhaz" -log(x)

Value

a tibble

Examples

survfit2(Surv(time, status) ~ factor(ph.ecog), data = df_lung) %>%
  tidy_survfit()

ggsurvfit documentation built on Nov. 2, 2023, 5:33 p.m.