Usage
s_surv_timepoint(
df,
.var,
time_point,
is_event,
control = control_surv_timepoint()
)
a_surv_timepoint(
df,
.var,
time_point,
is_event,
control = control_surv_timepoint()
)
s_surv_timepoint_diff(
df,
.var,
.ref_group,
.in_ref_col,
time_point,
control = control_surv_timepoint(),
...
)
a_surv_timepoint_diff(
df,
.var,
.ref_group,
.in_ref_col,
time_point,
control = control_surv_timepoint(),
...
)
surv_timepoint(
lyt,
vars,
...,
table_names_suffix = "",
var_labels = "Time",
show_labels = "visible",
method = c("surv", "surv_diff", "both"),
.stats = c("pt_at_risk", "event_free_rate", "rate_ci", "rate_diff", "rate_diff_ci",
"ztest_pval"),
.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.- time_point
(
number
)
survival time point of interest.- 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 functioncontrol_surv_timepoint
. Some possible parameter options are:conf_level
: (proportion
)
confidence level of the interval for survival rate.conf_type
: (string
)
"plain" (default), "log", "log-log" for confidence interval type,
see more insurvival::survfit()
. Note that the option "none" is no longer supported.time_point
: (number
)
survival time point of interest.
- .ref_group
(
data frame
orvector
)
the data corresponding to the reference group.- .in_ref_col
(
logical
)TRUE
when working with the reference level,FALSE
otherwise.- ...
additional arguments for the lower level functions.
- lyt
(
layout
)
input layout where analyses will be added to.- vars
(
character
)
variable names for the primary analysis variable to be iterated over.- table_names_suffix
(
string
)
optional suffix for thetable_names
used for thertables
to avoid warnings from duplicate table names.- var_labels
character for label.
- show_labels
label visibility: one of "default", "visible" and "hidden".
- method
(
string
)
eithersurv
(survival estimations),surv_diff
(difference in survival with the control) orboth
.- .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:
pt_at_risk
: patients remaining at risk.event_free_rate
: event free rate (%).rate_se
: standard error of event free rate.rate_ci
: confidence interval for event free rate.
The statistics are:
rate_diff
: event free rate difference between two groups.rate_diff_ci
: confidence interval for the difference.ztest_pval
: p-value to test the difference is 0.
Functions
s_surv_timepoint()
: Statistics Function which analyzes survival rate.a_surv_timepoint()
: Formatted Analysis function which can be further customized by callingrtables::make_afun()
on it. It is used asafun
inrtables::analyze()
.s_surv_timepoint_diff()
: Statistics Function which analyzes difference between two survival rates.a_surv_timepoint_diff()
: Formatted Analysis function which can be further customized by callingrtables::make_afun()
on it. It is used asafun
inrtables::analyze()
.surv_timepoint()
: Analyze Function which adds the survival rate 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_timepoint
if (FALSE) {
s_surv_timepoint(df, .var = "AVAL", time_point = 7, is_event = "is_event")
}
# Internal function - a_surv_timepoint
if (FALSE) {
a_surv_timepoint(df, .var = "AVAL", time_point = 7, is_event = "is_event")
}
df_ref_group <- ADTTE_f %>%
filter(ARMCD == "ARM B")
# Internal function - s_surv_timepoint_diff
if (FALSE) {
s_surv_timepoint_diff(df, df_ref_group, .in_ref_col = TRUE, .var = "AVAL", is_event = "is_event")
s_surv_timepoint_diff(
df,
df_ref_group,
.in_ref_col = FALSE,
.var = "AVAL",
time_point = 7,
is_event = "is_event"
)
}
# Internal function - a_surv_timepoint_diff
if (FALSE) {
a_surv_timepoint_diff(
df,
df_ref_group,
.in_ref_col = FALSE,
.var = "AVAL",
time_point = 7,
is_event = "is_event"
)
}
# Survival at given time points.
basic_table() %>%
split_cols_by(var = "ARMCD", ref_group = "ARM A") %>%
add_colcounts() %>%
surv_timepoint(
vars = "AVAL",
var_labels = "Months",
is_event = "is_event",
time_point = 7
) %>%
build_table(df = ADTTE_f)
#> ARM A ARM B ARM C
#> (N=134) (N=134) (N=132)
#> ———————————————————————————————————————————————————————————————————————————————
#> 7 Months
#> Patients remaining at risk 103 102 83
#> Event Free Rate (%) 83.83 82.73 66.98
#> 95% CI (77.49, 90.17) (76.15, 89.30) (58.79, 75.17)
# Difference in survival at given time points.
basic_table() %>%
split_cols_by(var = "ARMCD", ref_group = "ARM A") %>%
add_colcounts() %>%
surv_timepoint(
vars = "AVAL",
var_labels = "Months",
is_event = "is_event",
time_point = 9,
method = "surv_diff",
.indent_mods = c("rate_diff" = 0L, "rate_diff_ci" = 2L, "ztest_pval" = 2L)
) %>%
build_table(df = ADTTE_f)
#> ARM A ARM B ARM C
#> (N=134) (N=134) (N=132)
#> ————————————————————————————————————————————————————————————————————————————
#> 9 Months
#> Difference in Event Free Rate -4.34 -20.05
#> 95% CI (-14.48, 5.79) (-31.02, -9.09)
#> p-value (Z-test) 0.4012 0.0003
# Survival and difference in survival at given time points.
basic_table() %>%
split_cols_by(var = "ARMCD", ref_group = "ARM A") %>%
add_colcounts() %>%
surv_timepoint(
vars = "AVAL",
var_labels = "Months",
is_event = "is_event",
time_point = 9,
method = "both"
) %>%
build_table(df = ADTTE_f)
#> ARM A ARM B ARM C
#> (N=134) (N=134) (N=132)
#> —————————————————————————————————————————————————————————————————————————————————
#> 9 Months
#> Patients remaining at risk 97 93 73
#> Event Free Rate (%) 80.52 76.18 60.47
#> 95% CI (73.66, 87.39) (68.73, 83.64) (51.92, 69.02)
#> Difference in Event Free Rate -4.34 -20.05
#> 95% CI (-14.48, 5.79) (-31.02, -9.09)
#> p-value (Z-test) 0.4012 0.0003