@@ -73,58 +73,39 @@ print(params$ae_summary_log)
7373for (g in groups) {
7474 # pasting together the chosen arms of ARM A aka treatment arm and separating them by comma as well as removing the last comma
7575 ARMS_ARM_A <- substr(
76- paste0(cb_list_trt[[paste0("grp", g)]],
77- ", ",
78- collapse = ""
79- ),
76+ paste0(cb_list_trt[[paste0("grp", g)]], ", ", collapse = ""),
8077 STRING_START,
81- nchar(paste0(cb_list_trt[[paste0("grp", g)]],
82- ", ",
83- collapse = ""
84- )) - COMMA_PLUS_ONE_SPACE
78+ nchar(paste0(cb_list_trt[[paste0("grp", g)]], ", ", collapse = "")) -
79+ COMMA_PLUS_ONE_SPACE
8580 )
8681 # pasting together the chosen arms of ARM B aka control arm and separating them by comma as well as removing the last comma
8782 ARMS_ARM_B <- substr(
88- paste0(cb_list_ctr[[paste0("grp", g)]],
89- ", ",
90- collapse = ""
91- ),
83+ paste0(cb_list_ctr[[paste0("grp", g)]], ", ", collapse = ""),
9284 STRING_START,
93- nchar(paste0(cb_list_ctr[[paste0("grp", g)]],
94- ", ",
95- collapse = ""
96- )) - COMMA_PLUS_ONE_SPACE
85+ nchar(paste0(cb_list_ctr[[paste0("grp", g)]], ", ", collapse = "")) -
86+ COMMA_PLUS_ONE_SPACE
9787 )
9888 # list element as data frame for kableExtra
9989 list_comparisons[[g]] <- as.data.frame(
10090 cbind(
10191 # pasting together the IDs of ARM A aka treatment arm and separating them by comma as well as removing the last comma
10292 substr(
103- paste0(ID_trt_list[[paste0("grp", g)]],
104- ", ",
105- collapse = ""
106- ),
93+ paste0(ID_trt_list[[paste0("grp", g)]], ", ", collapse = ""),
10794 STRING_START,
108- nchar(paste0(ID_trt_list[[paste0("grp", g)]],
109- ", ",
110- collapse = ""
111- )) - COMMA_PLUS_ONE_SPACE
95+ nchar(paste0(ID_trt_list[[paste0("grp", g)]], ", ", collapse = "")) -
96+ COMMA_PLUS_ONE_SPACE
11297 ),
11398 # same with ARM B or control arm
11499 substr(
115- paste0(ID_ctr_list[[paste0("grp", g)]],
116- ", ",
117- collapse = ""
118- ),
100+ paste0(ID_ctr_list[[paste0("grp", g)]], ", ", collapse = ""),
119101 STRING_START,
120- nchar(paste0(ID_ctr_list[[paste0("grp", g)]],
121- ", ",
122- collapse = ""
123- )) - COMMA_PLUS_ONE_SPACE
102+ nchar(paste0(ID_ctr_list[[paste0("grp", g)]], ", ", collapse = "")) -
103+ COMMA_PLUS_ONE_SPACE
124104 )
125105 )
126106 )
127- table_comparisons <- kableExtra::kable(list_comparisons[[g]],
107+ table_comparisons <- kableExtra::kable(
108+ list_comparisons[[g]],
128109 format = "latex",
129110 # to enable a stable width of the table
130111 booktabs = TRUE,
@@ -145,20 +126,31 @@ for (g in groups) {
145126 ARMS_ARM_B
146127 )
147128
148-
149- list_table_1_1[[g]] <- cbind(as.data.frame(array_inci[, , 1, g, drop = FALSE]), as.data.frame(array_inci[, , 2, g, drop = FALSE]))
150- # list_table_1_1[[g]] <- list_table_1_1[[g]] |> na.omit()
151- list_table_1_1[[g]][, c(3, 10)] <- round(list_table_1_1[[g]][, c(3, 10)] * 100, 1)
152- list_table_1_1[[g]][, c(3, 10)] <- round(list_table_1_1[[g]][, c(3, 10)] * 100, 1)
153- table_display_1 <- kableExtra::kable(list_table_1_1[[g]],
129+ list_table_1_1[[g]] <- cbind(
130+ as.data.frame(array_inci[, , 1, g, drop = FALSE]),
131+ as.data.frame(array_inci[, , 2, g, drop = FALSE])
132+ )
133+ # nolintr list_table_1_1[[g]] <- list_table_1_1[[g]] |> na.omit()
134+ list_table_1_1[[g]][, c(3, 10)] <- round(
135+ list_table_1_1[[g]][, c(3, 10)] * 100,
136+ 1
137+ )
138+ list_table_1_1[[g]][, c(3, 10)] <- round(
139+ list_table_1_1[[g]][, c(3, 10)] * 100,
140+ 1
141+ )
142+ table_display_1 <- kableExtra::kable(
143+ list_table_1_1[[g]],
154144 format = "latex",
155- booktabs = TRUE, digits = 3,
145+ booktabs = TRUE,
146+ digits = 3,
156147 longtable = TRUE,
157148 col.names = rep(c("r", "n", "%", "mean", "median", "CRI L", "CRI U"), 2),
158149 caption = table_caption_1
159150 ) |>
160151 kableExtra::kable_styling(font_size = 8) |>
161- kableExtra::add_header_above( # adding extra separation layer of both Arms above the column names. They have to be equal to the names of the array/list
152+ kableExtra::add_header_above(
153+ # adding extra separation layer of both Arms above the column names. They have to be equal to the names of the array/list
162154 c(
163155 "Arm A" = 7,
164156 "Arm B" = 7
@@ -182,14 +174,22 @@ for (g in groups) {
182174 " vs. Arm B: ",
183175 ARMS_ARM_B
184176 )
185- list_table_1_2[[g]] <- cbind(as.data.frame(array_inci_comp[, , 1, g, drop = FALSE]), as.data.frame(array_inci_comp[, , 2, g, drop = FALSE]))
186- # list_table_1_2[[g]] <- as.data.frame(cbind(array_inci_comp[, , 1, g], array_inci_comp[, , 2, g]))
187- # list_table_1_2[[g]] <- list_table_1_2[[g]] |> na.omit()
188- table_display_2 <- kableExtra::kable(list_table_1_2[[g]][, -6],
177+ list_table_1_2[[g]] <- cbind(
178+ as.data.frame(array_inci_comp[, , 1, g, drop = FALSE]),
179+ as.data.frame(array_inci_comp[, , 2, g, drop = FALSE])
180+ )
181+ # nolintr list_table_1_2[[g]] <- as.data.frame(cbind(array_inci_comp[, , 1, g], array_inci_comp[, , 2, g]))
182+ # nolintr list_table_1_2[[g]] <- list_table_1_2[[g]] |> na.omit()
183+ table_display_2 <- kableExtra::kable(
184+ list_table_1_2[[g]][, -6],
189185 format = "latex",
190- booktabs = TRUE, digits = 3,
186+ booktabs = TRUE,
187+ digits = 3,
191188 longtable = TRUE,
192- col.names = c(rep(c("Naive", "mean", "median", "CRI L", "CRI U"), 2), "A>B%"),
189+ col.names = c(
190+ rep(c("Naive", "mean", "median", "CRI L", "CRI U"), 2),
191+ "A>B%"
192+ ),
193193 caption = table_caption_2
194194 ) |>
195195 kableExtra::kable_styling(font_size = 8) |>
@@ -222,12 +222,17 @@ for (g in groups) {
222222 " vs. Arm B: ",
223223 ARMS_ARM_B
224224 )
225- # list_table_2_1[[g]] <- as.data.frame(cbind(array_er[, , 1, g], array_er[, , 2, g]))
226- list_table_2_1[[g]] <- cbind(as.data.frame(array_er[, , 1, g, drop = FALSE]), as.data.frame(array_er[, , 2, g, drop = FALSE]))
227- # list_table_2_1[[g]] <- list_table_2_1[[g]] |> na.omit()
228- table_display_3 <- kableExtra::kable(list_table_2_1[[g]],
225+ # nolintr list_table_2_1[[g]] <- as.data.frame(cbind(array_er[, , 1, g], array_er[, , 2, g]))
226+ list_table_2_1[[g]] <- cbind(
227+ as.data.frame(array_er[, , 1, g, drop = FALSE]),
228+ as.data.frame(array_er[, , 2, g, drop = FALSE])
229+ )
230+ # nolintr list_table_2_1[[g]] <- list_table_2_1[[g]] |> na.omit()
231+ table_display_3 <- kableExtra::kable(
232+ list_table_2_1[[g]],
229233 format = "latex",
230- booktabs = TRUE, digits = 3,
234+ booktabs = TRUE,
235+ digits = 3,
231236 longtable = TRUE,
232237 col.names = rep(c("Naive", "mean", "median", "CRI L", "CRI U"), 2),
233238 caption = table_caption_3
@@ -260,17 +265,25 @@ for (g in groups) {
260265 " vs. Arm B: ",
261266 ARMS_ARM_B
262267 )
263- list_table_2_2[[g]] <- cbind(as.data.frame(array_er_comp[, , 1, g, drop = FALSE]), as.data.frame(array_er_comp[, , 2, g, drop = FALSE]))
264- # list_table_2_2[[g]] <- as.data.frame(cbind(array_er_comp[, , 1, g], array_er_comp[, , 2, g]))
265- # list_table_2_2[[g]] <- list_table_2_2[[g]] |> na.omit()
268+ list_table_2_2[[g]] <- cbind(
269+ as.data.frame(array_er_comp[, , 1, g, drop = FALSE]),
270+ as.data.frame(array_er_comp[, , 2, g, drop = FALSE])
271+ )
272+ # nolintr list_table_2_2[[g]] <- as.data.frame(cbind(array_er_comp[, , 1, g], array_er_comp[, , 2, g]))
273+ # nolintr list_table_2_2[[g]] <- list_table_2_2[[g]] |> na.omit()
266274 if (length(list_table_2_2[[g]]) == 0) {
267275 print("Analysis is not applicable!")
268276 } else {
269- table_display_4 <- kableExtra::kable(list_table_2_2[[g]][, -6],
277+ table_display_4 <- kableExtra::kable(
278+ list_table_2_2[[g]][, -6],
270279 format = "latex",
271- booktabs = TRUE, digits = 3,
280+ booktabs = TRUE,
281+ digits = 3,
272282 longtable = TRUE,
273- col.names = c(rep(c("Naive", "mean", "median", "CRI L", "CRI U"), 2), "A>B%"),
283+ col.names = c(
284+ rep(c("Naive", "mean", "median", "CRI L", "CRI U"), 2),
285+ "A>B%"
286+ ),
274287 caption = table_caption_4
275288 ) |>
276289 kableExtra::kable_styling(font_size = 8) |>
0 commit comments