response_subgroups | R Documentation |
Tabulate statistics such as response rate and odds ratio for population subgroups.
tabulate_rsp_subgroups(
lyt,
df,
vars = c("n_tot", "n", "prop", "or", "ci"),
groups_lists = list(),
label_all = "All Patients",
na_str = default_na_str()
)
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)"),
na_str = default_na_str()
)
lyt |
( |
df |
( |
vars |
(
|
groups_lists |
(named |
label_all |
( |
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")
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.