Usage
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)")
)
tabulate_rsp_subgroups(lyt, df, vars = c("n_tot", "n", "prop", "or", "ci"))
Arguments
- .formats
(named
character
orlist
)
formats for the statistics. See Details inanalyze_vars
for more information on the"auto"
setting.- lyt
(
layout
)
input layout where analyses will be added to.- df
(
list
)
of data frames containing all analysis variables. List should be created usingextract_rsp_subgroups()
.- vars
-
(
character
)
the names of statistics to be reported among:n
: Total number of observations per group.n_rsp
: Number of responders per group.prop
: Proportion of responders.n_tot
: Total number of observations.or
: Odds ratio.ci
: Confidence interval of odds ratio.pval
: p-value of the effect. Note, the statisticsn_tot
,or
andci
are required.
Value
a_response_subgroups()
returns the corresponding list with formattedrtables::CellValue()
.
An rtables
table summarizing binary response by subgroup.
Details
These functions create a layout starting from a data frame which contains the required statistics. Tables typically used as part of forest plot.
Functions
a_response_subgroups()
: Formatted analysis function which is used asafun
intabulate_rsp_subgroups()
.tabulate_rsp_subgroups()
: Table-creating function which creates a table summarizing binary response by subgroup. This function is a wrapper forrtables::analyze_colvars()
andrtables::summarize_row_groups()
.
Examples
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
#> $prop
#> arm n n_rsp prop subgroup var
#> 1 B: Placebo 73 50 0.6849315 All Patients ALL
#> 2 A: Drug X 69 59 0.8550725 All Patients ALL
#> 3 B: Placebo 40 25 0.6250000 F SEX
#> 4 A: Drug X 38 36 0.9473684 F SEX
#> 5 B: Placebo 33 25 0.7575758 M SEX
#> 6 A: Drug X 31 23 0.7419355 M SEX
#> 7 B: Placebo 24 13 0.5416667 LOW BMRKR2
#> 8 A: Drug X 26 21 0.8076923 LOW BMRKR2
#> 9 B: Placebo 23 17 0.7391304 MEDIUM BMRKR2
#> 10 A: Drug X 26 23 0.8846154 MEDIUM BMRKR2
#> 11 B: Placebo 26 20 0.7692308 HIGH BMRKR2
#> 12 A: Drug X 17 15 0.8823529 HIGH BMRKR2
#> var_label row_type
#> 1 All Patients content
#> 2 All Patients content
#> 3 Sex analysis
#> 4 Sex analysis
#> 5 Sex analysis
#> 6 Sex analysis
#> 7 Continuous Level Biomarker 2 analysis
#> 8 Continuous Level Biomarker 2 analysis
#> 9 Continuous Level Biomarker 2 analysis
#> 10 Continuous Level Biomarker 2 analysis
#> 11 Continuous Level Biomarker 2 analysis
#> 12 Continuous Level Biomarker 2 analysis
#>
#> $or
#> arm n_tot or lcl ucl conf_level subgroup var
#> 1 142 2.714000 1.1804488 6.239827 0.95 All Patients ALL
#> 2 78 10.800000 2.2669576 51.452218 0.95 F SEX
#> 3 64 0.920000 0.2966470 2.853223 0.95 M SEX
#> 4 50 3.553846 1.0047370 12.570277 0.95 LOW BMRKR2
#> 5 49 2.705882 0.5911718 12.385232 0.95 MEDIUM BMRKR2
#> 6 43 2.250000 0.3970298 12.750933 0.95 HIGH BMRKR2
#> var_label row_type
#> 1 All Patients content
#> 2 Sex analysis
#> 3 Sex analysis
#> 4 Continuous Level Biomarker 2 analysis
#> 5 Continuous Level Biomarker 2 analysis
#> 6 Continuous Level Biomarker 2 analysis
#>
## Table with default columns.
basic_table() %>%
tabulate_rsp_subgroups(df)
#> B: Placebo A: Drug X
#> Baseline Risk Factors Total n n Response (%) n Response (%) Odds Ratio 95% CI
#> ———————————————————————————————————————————————————————————————————————————————————————————————————————————
#> All Patients 142 73 68.5% 69 85.5% 2.71 (1.18, 6.24)
#> Sex
#> F 78 40 62.5% 38 94.7% 10.80 (2.27, 51.45)
#> M 64 33 75.8% 31 74.2% 0.92 (0.30, 2.85)
#> Continuous Level Biomarker 2
#> LOW 50 24 54.2% 26 80.8% 3.55 (1.00, 12.57)
#> MEDIUM 49 23 73.9% 26 88.5% 2.71 (0.59, 12.39)
#> HIGH 43 26 76.9% 17 88.2% 2.25 (0.40, 12.75)
## Table with selected columns.
basic_table() %>%
tabulate_rsp_subgroups(
df = df,
vars = c("n_tot", "n", "n_rsp", "prop", "or", "ci")
)
#> B: Placebo A: Drug X
#> Baseline Risk Factors Total n n Responders Response (%) n Responders Response (%) Odds Ratio 95% CI
#> —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
#> All Patients 142 73 50 68.5% 69 59 85.5% 2.71 (1.18, 6.24)
#> Sex
#> F 78 40 25 62.5% 38 36 94.7% 10.80 (2.27, 51.45)
#> M 64 33 25 75.8% 31 23 74.2% 0.92 (0.30, 2.85)
#> Continuous Level Biomarker 2
#> LOW 50 24 13 54.2% 26 21 80.8% 3.55 (1.00, 12.57)
#> MEDIUM 49 23 17 73.9% 26 23 88.5% 2.71 (0.59, 12.39)
#> HIGH 43 26 20 76.9% 17 15 88.2% 2.25 (0.40, 12.75)