Step 1: Define some utility functions
- Format Confidence Interval
The table consists of three data frames: t1
,
t2
, and t3
. We define each data frame’s format
as below then combine them into a listing.
tbl_1 <- t1 %>%
rtf_title(
title = "ANCOVA of Change from Baseline at Week 20",
subtitle = c(
"Missing Data Approach",
"Analysis Population"
)
) %>%
rtf_colheader(
colheader = " | Baseline | Week 20 | Change from Baseline",
col_rel_width = c(3, 4, 4, 9)
) %>%
rtf_colheader(
colheader = "Treatment | N | Mean (SD) | N | Mean (SD) | N | Mean (SD) | LS Mean (95% CI){^a}",
col_rel_width = c(3, 1, 3, 1, 3, 1, 3, 5)
) %>%
rtf_body(
col_rel_width = c(3, 1, 3, 1, 3, 1, 3, 5),
text_justification = c("l", rep("c", 7)),
last_row = FALSE
) %>%
rtf_footnote(
footnote = c(
"{^a}Based on an ANCOVA model.",
"ANCOVA = Analysis of Covariance, CI = Confidence Interval, LS = Least Squares, SD = Standard Deviation"
)
) %>%
rtf_source(
source = "Source: [study999: adam-adeff]"
)
tbl_2 <- t2 %>%
rtf_colheader(
colheader = "Pairwise Comparison | Difference in LS Mean (95% CI){^a} | p-Value",
text_justification = c("l", "c", "c"),
col_rel_width = c(8, 7, 5)
) %>%
rtf_body(
col_rel_width = c(8, 7, 5),
text_justification = c("l", "c", "c"),
last_row = FALSE
)
tbl_3 <- t3 %>%
rtf_body(
as_colheader = FALSE,
col_rel_width = c(1),
text_justification = "l"
)
tbl <- list(tbl_1, tbl_2, tbl_3)
Study Drug |
61 |
16.6 (4.41) |
61 |
-6.6 (5.95) |
61 |
-7.0 (9.16) |
-7.0 (-8.58, -5.38) |
Placebo |
70 |
18.4 (6.34) |
70 |
-9.0 (7.04) |
70 |
-8.7 (8.54) |
-8.7 (-10.17, -7.18) |
|
Study Drug vs. Placebo |
1.7 (-0.49, 3.88) |
0.130 |
|
Root Mean Squared Error of Change = 6.23 |
|