response_subgroups | R Documentation |
The tabulate_rsp_subgroups()
function creates a layout element to tabulate binary response by subgroup, returning
statistics including response rate and odds ratio for each population subgroup. The table is created from df
, a
list of data frames returned by extract_rsp_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_rsp_subgroups(
lyt,
df,
vars = c("n_tot", "n", "prop", "or", "ci"),
groups_lists = list(),
label_all = "All Patients",
riskdiff = NULL,
na_str = default_na_str(),
.formats = c(n = "xx", n_rsp = "xx", prop = "xx.x%", n_tot = "xx", or =
list(format_extreme_values(2L)), ci = list(format_extreme_values_ci(2L)), pval =
"x.xxxx | (<0.0001)")
)
a_response_subgroups(
.formats = list(n = "xx", n_rsp = "xx", prop = "xx.x%", n_tot = "xx", or =
list(format_extreme_values(2L)), ci = list(format_extreme_values_ci(2L)), pval =
"x.xxxx | (<0.0001)", riskdiff = "xx.x (xx.x - xx.x)"),
na_str = default_na_str()
)
lyt |
( |
df |
( |
vars |
(
|
groups_lists |
(named |
label_all |
( |
riskdiff |
( |
na_str |
( |
.formats |
(named |
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 binary response by subgroup.
a_response_subgroups()
returns the corresponding list with formatted rtables::CellValue()
.
tabulate_rsp_subgroups()
: Table-creating function which creates a table
summarizing binary response by subgroup. This function is a wrapper for rtables::analyze_colvars()
and rtables::summarize_row_groups()
.
a_response_subgroups()
: Formatted analysis function which is used as afun
in tabulate_rsp_subgroups()
.
extract_rsp_subgroups()
library(dplyr)
library(forcats)
adrs <- tern_ex_adrs
adrs_labels <- formatters::var_labels(adrs)
adrs_f <- adrs %>%
filter(PARAMCD == "BESRSPI") %>%
filter(ARM %in% c("A: Drug X", "B: Placebo")) %>%
droplevels() %>%
mutate(
# Reorder levels of factor to make the placebo group the reference arm.
ARM = fct_relevel(ARM, "B: Placebo"),
rsp = AVALC == "CR"
)
formatters::var_labels(adrs_f) <- c(adrs_labels, "Response")
# Unstratified analysis.
df <- extract_rsp_subgroups(
variables = list(rsp = "rsp", arm = "ARM", subgroups = c("SEX", "BMRKR2")),
data = adrs_f
)
df
# Stratified analysis.
df_strat <- extract_rsp_subgroups(
variables = list(rsp = "rsp", arm = "ARM", subgroups = c("SEX", "BMRKR2"), strata = "STRATA1"),
data = adrs_f
)
df_strat
# Grouping of the BMRKR2 levels.
df_grouped <- extract_rsp_subgroups(
variables = list(rsp = "rsp", arm = "ARM", subgroups = c("SEX", "BMRKR2")),
data = adrs_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_rsp_subgroups(df)
# Table with selected columns
basic_table() %>%
tabulate_rsp_subgroups(
df = df,
vars = c("n_tot", "n", "n_rsp", "prop", "or", "ci")
)
# Table with risk difference column added
basic_table() %>%
tabulate_rsp_subgroups(
df,
riskdiff = control_riskdiff(
arm_x = levels(df$prop$arm)[1],
arm_y = levels(df$prop$arm)[2]
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.