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 = NULL
)
Arguments
- df
(
data frame
)
data set containing all analysis variables.- .var
(
string
)
single variable name that is passed byrtables
when requested by a statistics function.- is_event
(
logical
)TRUE
if event,FALSE
if time to event is censored.- control
-
a (
list
) of parameters for comparison details, specified by using
the helper function control_surv_time. Some possible parameter options are:conf_level
: (proportion
)
confidence level of the interval for survival time.conf_type
: (string
)
"plain" (default), "log", "log-log" for confidence interval type,
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 for label.
- table_names
(
character
)
this can be customized in case that the samevars
are analyzed multiple times, to avoid warnings fromrtables
.- .stats
(
character
)
statistics to select for the table.- .formats
(named
character
orlist
)
formats for the statistics.- .labels
(named
character
)
labels for the statistics (without indent).- .indent_mods
(named
integer
)
indent modifiers for the labels.
Value
The statistics are:
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.
Functions
s_surv_time()
: Statistics Function which analyzes survival times.range_censor
andrange_event
.a_surv_time()
: Formatted Analysis function which can be further customized by callingrtables::make_afun()
on it. It is used asafun
inrtables::analyze()
.surv_time()
: Analyze Function which adds the survival times analysis to the input layout. Note that additional formatting arguments can be used here.
Examples
library(scda)
library(dplyr)
ADTTE <- synthetic_cdisc_data("latest")$adtte
ADTTE_f <- ADTTE %>%
filter(PARAMCD == "OS") %>%
mutate(
AVAL = day2month(AVAL),
is_event = CNSR == 0
)
df <- ADTTE_f %>% filter(ARMCD == "ARM A")
# Internal function - s_surv_time
if (FALSE) {
s_surv_time(df, .var = "AVAL", is_event = "is_event")
}
# Internal function - a_surv_time
if (FALSE) {
a_surv_time(df, .var = "AVAL", is_event = "is_event")
}
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=134) (N=134) (N=132)
#> ———————————————————————————————————————————————————————————————————
#> Survival Time (Months)
#> Median 41.4 27.5 11.1
#> 90% CI (27.9, 54.1) (18.8, 29.9) (9.7, 15.1)
#> 25% and 75%-ile 15.4, 75.2 9.5, 54.9 5.3, 25.2
#> Range (censored) 0.4 to 154.7 0.9 to 91.0 0.3 to 49.4
#> Range (event) 0.3 to 116.4 0.0 to 122.4 0.1 to 101.6