Summarize median survival time and CIs, percentiles of survival times, survival time range of censored/event patients.
Usage
s_surv_time(df, .var, is_event, control = control_surv_time())
a_surv_time(df, .var, is_event, control = control_surv_time())
surv_time(
lyt,
vars,
...,
var_labels = "Time to Event",
table_names = vars,
.stats = c("median", "median_ci", "quantiles", "range_censor", "range_event"),
.formats = NULL,
.labels = NULL,
.indent_mods = c(median = 0L, median_ci = 1L, quantiles = 0L, range_censor = 0L,
range_event = 0L, range = 0L)
)Arguments
- df
(
data.frame)
data set containing all analysis variables.- .var
(
string)
single variable name that is passed byrtableswhen requested by a statistics function.- is_event
(
logical)TRUEif event,FALSEif time to event is censored.- control
-
(
list)
parameters for comparison details, specified by using the helper functioncontrol_surv_time(). Some possible parameter options are:conf_level(proportion)
confidence level of the interval for survival time.conf_type(string)
confidence interval type. Options are "plain" (default), "log", or "log-log", see more insurvival::survfit(). Note option "none" is not supported.quantiles(numeric)
vector of length two to specify the quantiles of survival time.
- lyt
(
layout)
input layout where analyses will be added to.- vars
(
character)
variable names for the primary analysis variable to be iterated over.- ...
additional arguments for the lower level functions.
- var_labels
(
character)
character for label.- table_names
(
character)
this can be customized in case that the samevarsare analyzed multiple times, to avoid warnings fromrtables.- .stats
(
character)
statistics to select for the table.- .formats
(named
characterorlist)
formats for the statistics.- .labels
(named
character)
labels for the statistics (without indent).- .indent_mods
(named
vectorofinteger)
indent modifiers for the labels. Each element of the vector should be a name-value pair with name corresponding to a statistic specified in.statsand value the indentation for that statistic's row label.
Value
-
s_surv_time()returns the statistics:median: Median survival time.median_ci: Confidence interval for median time.quantiles: Survival time for two specified quantiles.range_censor: Survival time range for censored observations.range_event: Survival time range for observations with events.range: Survival time range for all observations.
a_surv_time()returns the corresponding list with formattedrtables::CellValue().
surv_time()returns a layout object suitable for passing to further layouting functions, or tortables::build_table(). Adding this function to anrtablelayout will add formatted rows containing the statistics froms_surv_time()to the table layout.
Functions
s_surv_time(): Statistics function which analyzes survival times.a_surv_time(): Formatted analysis function which is used asafuninsurv_time().surv_time(): Layout-creating function which can take statistics function arguments and additional format arguments. This function is a wrapper forrtables::analyze().
Examples
library(dplyr)
adtte_f <- tern_ex_adtte %>%
filter(PARAMCD == "OS") %>%
mutate(
AVAL = day2month(AVAL),
is_event = CNSR == 0
)
df <- adtte_f %>% filter(ARMCD == "ARM A")
basic_table() %>%
split_cols_by(var = "ARMCD") %>%
add_colcounts() %>%
surv_time(
vars = "AVAL",
var_labels = "Survival Time (Months)",
is_event = "is_event",
control = control_surv_time(conf_level = 0.9, conf_type = "log-log")
) %>%
build_table(df = adtte_f)
#> ARM A ARM B ARM C
#> (N=69) (N=73) (N=58)
#> ———————————————————————————————————————————————————————————————————
#> Survival Time (Months)
#> Median 32.0 23.9 20.8
#> 90% CI (22.6, 46.5) (18.3, 29.2) (12.9, 25.9)
#> 25% and 75%-ile 17.4, 65.3 9.8, 42.0 7.3, 37.1
#> Range (censored) 0.8 to 63.5 6.2 to 78.9 3.4 to 52.4
#> Range (event) 0.3 to 155.5 0.1 to 154.1 0.6 to 80.7