survival_duration_subgroups | R Documentation |
The tabulate_survival_subgroups()
function creates a layout element to tabulate survival duration by subgroup,
returning statistics including median survival time and hazard ratio for each population subgroup. The table is
created from df
, a list of data frames returned by extract_survival_subgroups()
, with the statistics to include
specified via the vars
parameter.
A forest plot can be created from the resulting table using the g_forest()
function.
tabulate_survival_subgroups(
lyt,
df,
vars = c("n_tot_events", "n_events", "median", "hr", "ci"),
groups_lists = list(),
label_all = lifecycle::deprecated(),
time_unit = NULL,
riskdiff = NULL,
na_str = default_na_str(),
.formats = c(n = "xx", n_events = "xx", n_tot_events = "xx", median = "xx.x", n_tot =
"xx", hr = list(format_extreme_values(2L)), ci = list(format_extreme_values_ci(2L)),
pval = "x.xxxx | (<0.0001)")
)
a_survival_subgroups(
.formats = list(n = "xx", n_events = "xx", n_tot_events = "xx", median = "xx.x", n_tot
= "xx", hr = list(format_extreme_values(2L)), ci =
list(format_extreme_values_ci(2L)), pval = "x.xxxx | (<0.0001)"),
na_str = default_na_str()
)
These functions create a layout starting from a data frame which contains the required statistics. Tables typically used as part of forest plot.
An rtables
table summarizing survival by subgroup.
a_survival_subgroups()
returns the corresponding list with formatted rtables::CellValue()
.
tabulate_survival_subgroups()
: Table-creating function which creates a table
summarizing survival by subgroup. This function is a wrapper for rtables::analyze_colvars()
and rtables::summarize_row_groups()
.
a_survival_subgroups()
: Formatted analysis function which is used as
afun
in tabulate_survival_subgroups()
.
extract_survival_subgroups()
library(dplyr)
adtte <- tern_ex_adtte
# Save variable labels before data processing steps.
adtte_labels <- formatters::var_labels(adtte)
adtte_f <- adtte %>%
filter(
PARAMCD == "OS",
ARM %in% c("B: Placebo", "A: Drug X"),
SEX %in% c("M", "F")
) %>%
mutate(
# Reorder levels of ARM to display reference arm before treatment arm.
ARM = droplevels(forcats::fct_relevel(ARM, "B: Placebo")),
SEX = droplevels(SEX),
AVALU = as.character(AVALU),
is_event = CNSR == 0
)
labels <- c(
"ARM" = adtte_labels[["ARM"]],
"SEX" = adtte_labels[["SEX"]],
"AVALU" = adtte_labels[["AVALU"]],
"is_event" = "Event Flag"
)
formatters::var_labels(adtte_f)[names(labels)] <- labels
df <- extract_survival_subgroups(
variables = list(
tte = "AVAL",
is_event = "is_event",
arm = "ARM", subgroups = c("SEX", "BMRKR2")
),
label_all = "Total Patients",
data = adtte_f
)
df
df_grouped <- extract_survival_subgroups(
variables = list(
tte = "AVAL",
is_event = "is_event",
arm = "ARM", subgroups = c("SEX", "BMRKR2")
),
data = adtte_f,
groups_lists = list(
BMRKR2 = list(
"low" = "LOW",
"low/medium" = c("LOW", "MEDIUM"),
"low/medium/high" = c("LOW", "MEDIUM", "HIGH")
)
)
)
df_grouped
## Table with default columns.
basic_table() %>%
tabulate_survival_subgroups(df, time_unit = adtte_f$AVALU[1])
## Table with a manually chosen set of columns: adding "pval".
basic_table() %>%
tabulate_survival_subgroups(
df = df,
vars = c("n_tot_events", "n_events", "median", "hr", "ci", "pval"),
time_unit = adtte_f$AVALU[1]
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.