# Example 1 ----------------------------------
# stacking two tbl_regression objects
t1 <-
glm(response ~ trt, trial, family = binomial) %>%
tbl_regression(
exponentiate = TRUE,
label = list(trt ~ "Treatment (unadjusted)")
)
t2 <-
glm(response ~ trt + grade + stage + marker, trial, family = binomial) %>%
tbl_regression(
include = "trt",
exponentiate = TRUE,
label = list(trt ~ "Treatment (adjusted)")
)
tbl_stack(list(t1, t2))
Characteristic |
OR |
95% CI |
p-value |
---|
Treatment (unadjusted) |
|
|
|
Drug A |
— |
— |
|
Drug B |
1.21 |
0.66, 2.24 |
0.5 |
Treatment (adjusted) |
|
|
|
Drug A |
— |
— |
|
Drug B |
1.48 |
0.78, 2.86 |
0.2 |
Abbreviations: CI = Confidence Interval, OR = Odds Ratio |
# Example 2 ----------------------------------
# stacking two tbl_merge objects
library(survival)
t3 <-
coxph(Surv(ttdeath, death) ~ trt, trial) %>%
tbl_regression(
exponentiate = TRUE,
label = list(trt ~ "Treatment (unadjusted)")
)
t4 <-
coxph(Surv(ttdeath, death) ~ trt + grade + stage + marker, trial) %>%
tbl_regression(
include = "trt",
exponentiate = TRUE,
label = list(trt ~ "Treatment (adjusted)")
)
# first merging, then stacking
row1 <- tbl_merge(list(t1, t3), tab_spanner = c("Tumor Response", "Death"))
row2 <- tbl_merge(list(t2, t4))
tbl_stack(list(row1, row2), group_header = c("Unadjusted Analysis", "Adjusted Analysis"))
Characteristic |
Tumor Response
|
Death
|
---|
OR |
95% CI |
p-value |
HR |
95% CI |
p-value |
---|
Unadjusted Analysis |
---|
Treatment (unadjusted) |
|
|
|
|
|
|
Drug A |
— |
— |
|
— |
— |
|
Drug B |
1.21 |
0.66, 2.24 |
0.5 |
1.25 |
0.86, 1.81 |
0.2 |
Adjusted Analysis |
---|
Treatment (adjusted) |
|
|
|
|
|
|
Drug A |
— |
— |
|
— |
— |
|
Drug B |
1.48 |
0.78, 2.86 |
0.2 |
1.30 |
0.88, 1.92 |
0.2 |
Abbreviations: CI = Confidence Interval, HR = Hazard Ratio, OR = Odds Ratio |