Learn R Programming

ggsurvfit (version 1.1.0)

tidy_survfit: 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", "cloglog")
)

Value

a tibble

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 or a function:

typetransformation
"survival"x
"risk"1 - x
"cumhaz"-log(x)
"cloglog"log(-log(x))

Examples

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

Run the code above in your browser using DataLab