Create a gtsummary table with Kaplan-Meier estimated survival estimates and specified times.
tbl_survfit_times(
data,
times,
y = "survival::Surv(time = AVAL, event = 1 - CNSR, type = 'right', origin = 0)",
by = NULL,
label = "Time {time}",
statistic = c("{n.risk}", "{estimate}%", "{conf.low}%, {conf.high}%"),
estimate_fun = label_roche_number(digits = 1, scale = 100),
method.args = list(conf.int = 0.95)
)
# S3 method for class 'tbl_survfit_times'
add_overall(
x,
last = FALSE,
col_label = "All Participants \nN = {style_roche_number(N)}",
...
)(data.frame)
A data frame
(numeric)
a vector of times for which to return survival probabilities.
(string or expression)
A string or expression with the survival outcome, e.g. survival::Surv(time, status).
The default value is
survival::Surv(time = AVAL, event = 1 - CNSR, type = "right", origin = 0).
(tidy-select)
A single column from data. Summary statistics will be stratified by this variable.
Default is NULL, which returns results for the unstratified model.
(string)
Label to appear in the header row. Default is "Time {time}", where
the glue syntax injects the time estimate into the label.
(character)
Character vector of the statistics to report.
May use any of the following statistics:
c(n.risk, estimate, std.error, conf.low, conf.high),
Default is c("{n.risk}", "{estimate}%", "{conf.low}%, {conf.high}%")
(function)
Function used to style/round the c(estimate, conf.low, conf.high) statistics.
(named list)
Named list of arguments that will be passed to survival::survfit().
Note that this list may contain non-standard evaluation components, and
must be handled similarly to tidyselect inputs by using
rlang's embrace operator {{ . }} or !!enquo() when programming with this
function.
(tbl_survfit_times)
A stratified 'tbl_survfit_times' object
(scalar logical)
Logical indicator to display overall column last in table.
Default is FALSE, which will display overall column first.
(string)
String indicating the column label. Default is "**Overall** \nN = {style_number(N)}"
These dots are for future extensions and must be empty.
a gtsummary table
When the statistic argument is modified, the statistic labels will likely
also need to be updated. To change the label, call the modify_table_body()
function to directly update the underlying x$table_body data frame.
# Example 1 ----------------------------------
tbl_survfit_times(
data = cards::ADTTE,
by = "TRTA",
times = c(30, 60),
label = "Day {time}"
) |>
add_overall()
All Participants
N = 254
Placebo
(N = 86)
Xanomeline High Dose
(N = 84)
Xanomeline Low Dose
(N = 84)