Summarise Kaplan-Meier follow-up with total N, events, censoring, and median survival with a 95
Arguments
- data
A
data.framecontaining survival time and event status.- time
Survival follow-up time. Quoted and bare names are accepted.
- event
Event indicator. Quoted and bare names are accepted. Numeric
0/1, numeric1/2, logical, character, and factor variables are accepted. For two-level character or factor variables, the second level is treated as the event.- by
Optional grouping variable for separate Kaplan-Meier summaries. Quoted and bare names are accepted.
- digits
Number of digits for survival time summaries.
- format
Output format. One of
"flextable"(default),"gt", or"tibble".- theme
Table styling preset.
Value
A list of class c("gtregression","survival_summary", ...)
with elements:
tableA
flextable,gt_tbl, orNULLwhenformat = "tibble".table_bodyTibble with numeric Kaplan-Meier summaries.
table_displayDisplay data frame used to render the table.
fitFitted
survfitobject.time,event,by,format,sourceMetadata fields.
Details
Median survival is estimated from survival::survfit(). If the median
survival time is not reached during follow-up, the display table shows
"Not reached".
Examples
lung_data <- data_lungcancer
lung_data$trt <- factor(lung_data$trt, levels = c(1, 2),
labels = c("Standard", "Test"))
survival_summary(
data = lung_data,
time = time,
event = status,
by = trt
)
survival_summary(
data = lung_data,
time = "time",
event = "status",
format = tibble
)
#> # A tibble: 1 × 7
#> Group N Events Censored Median CI.lower CI.upper
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 Overall 137 128 9 80 52 105