@@ -29,6 +29,51 @@ rob_blobbogram <- function(rma,
29
29
add_tests = TRUE ,
30
30
... ){
31
31
32
+ rob <- rob_append_weights(rob , rma )
33
+
34
+ # Set opinionated defaults for forester::forester()
35
+
36
+ forester_args <- list (... )
37
+
38
+ # If no file path is passed to the dots (...), make it a temporary directory,
39
+ # to comply with CRAN's policies on writing to the users computer
40
+ if (hasArg(" file_path" ) == FALSE ) {
41
+ file_path <- tempfile(fileext = " .png" )
42
+ } else {
43
+ file_path <- forester_args $ file_path
44
+ forester_args $ file_path <- NULL
45
+ }
46
+
47
+ if (hasArg(" font_family" ) == FALSE ) {
48
+ font_family <- " sans"
49
+ } else {
50
+ font_family <- forester_args $ font_family
51
+ forester_args $ font_family <- NULL
52
+ }
53
+
54
+ if (hasArg(" estimate_precision" ) == FALSE ) {
55
+ estimate_precision <- 2
56
+ } else {
57
+ estimate_precision <- forester_args $ estimate_precision
58
+ forester_args $ estimate_precision <- NULL
59
+ }
60
+
61
+ if (hasArg(" null_line_at" ) == FALSE ) {
62
+ null_line_at <- 1
63
+ } else {
64
+ null_line_at <- forester_args $ null_line_at
65
+ forester_args $ null_line_at <- NULL
66
+ }
67
+
68
+ if (hasArg(" x_scale_linear" ) == FALSE ) {
69
+ x_scale_linear <- FALSE
70
+ } else {
71
+ x_scale_linear <- forester_args $ x_scale_linear
72
+ forester_args $ x_scale_linear <- NULL
73
+ }
74
+
75
+ # Create the correctly formatted table
76
+
32
77
data <- metafor_object_to_table(rma ,
33
78
rob ,
34
79
subset_col = subset_col ,
@@ -41,14 +86,23 @@ rob_blobbogram <- function(rma,
41
86
rob_plot <- select_rob_columns(data , rob_tool ) %> %
42
87
appendable_rob_ggplot(rob_tool = rob_tool ,
43
88
rob_colour = rob_colour ,
44
- space_last = space_last )
45
-
46
- forester :: forester(dplyr :: select(data , Study ),
47
- data $ est ,
48
- data $ ci_low ,
49
- data $ ci_high ,
50
- add_plot = rob_plot ,
51
- ... )
89
+ space_last = space_last , font_family = font_family )
90
+
91
+ do.call(forester :: forester , c(
92
+ list (
93
+ dplyr :: select(data , Study ),
94
+ data $ est ,
95
+ data $ ci_low ,
96
+ data $ ci_high ,
97
+ add_plot = rob_plot ,
98
+ file_path = file_path ,
99
+ font_family = font_family ,
100
+ estimate_precision = estimate_precision ,
101
+ null_line_at = null_line_at ,
102
+ x_scale_linear = x_scale_linear
103
+ ),
104
+ forester_args
105
+ ))
52
106
53
107
}
54
108
@@ -111,7 +165,7 @@ create_title_row <- function(title){
111
165
return (data.frame (Study = title , est = NA , ci_low = NA , ci_high = NA ))
112
166
}
113
167
114
- appendable_rob_ggplot <- function (rob_gdata , space_last = TRUE , rob_tool = " ROB2" , rob_colour = " cochrane" ){
168
+ appendable_rob_ggplot <- function (rob_gdata , space_last = TRUE , rob_tool = " ROB2" , rob_colour = " cochrane" , font_family = " sans " ){
115
169
# given a data frame with arbitrary column names, makes a rob plot with those columns
116
170
# when space_last = true, separates the last column by a half width (usually for an overall)
117
171
# NA rows indicate spaces
@@ -134,7 +188,7 @@ appendable_rob_ggplot <- function(rob_gdata, space_last = TRUE, rob_tool = "ROB2
134
188
135
189
rob_colours <- get_colour(rob_tool , rob_colour )
136
190
137
- if (rob_tool == " Robins " ){
191
+ if (rob_tool == " ROBINS-I " ){
138
192
bias_colours <- c(" Critical" = rob_colours $ critical_colour ,
139
193
" Serious" = rob_colours $ high_colour ,
140
194
" Moderate" = rob_colours $ concerns_colour ,
@@ -167,12 +221,12 @@ appendable_rob_ggplot <- function(rob_gdata, space_last = TRUE, rob_tool = "ROB2
167
221
xmax = .data $ xmax ,
168
222
ymax = .data $ ymax ),
169
223
fill = " white" ,
170
- colour = " #eff3f2 " ) +
224
+ colour = " #a9a9a9 " ) +
171
225
ggplot2 :: geom_point(size = 5 , ggplot2 :: aes(x = .data $ x , y = .data $ row_num , colour = .data $ colour )) +
172
226
ggplot2 :: geom_point(size = 3 , ggplot2 :: aes(x = .data $ x , y = .data $ row_num , shape = .data $ colour )) +
173
227
ggplot2 :: scale_y_continuous(expand = c(0 ,0 )) + # position dots
174
228
ggplot2 :: scale_x_continuous(expand = c(0 ,0 ), limits = c(0 , (max(rob_gdata $ x ) + 1 ))) +
175
- ggplot2 :: geom_text(data = titles , ggplot2 :: aes(label = .data $ names , x = .data $ x , y = .data $ y )) +
229
+ ggplot2 :: geom_text(data = titles , ggplot2 :: aes(label = .data $ names , x = .data $ x , y = .data $ y ), family = font_family , fontface = " bold " ) +
176
230
ggplot2 :: scale_color_manual(values = bias_colours ,
177
231
na.translate = FALSE ) +
178
232
ggplot2 :: scale_shape_manual(
@@ -211,6 +265,8 @@ metafor_object_to_table <- function(rma,
211
265
# Reorder data
212
266
table <- dplyr :: select(table , Study , dplyr :: everything())
213
267
268
+ if (! is.null(subset_col )) {
269
+
214
270
# Clean level names so that they look nice in the table
215
271
table [[subset_col ]] <- stringr :: str_to_sentence(table [[subset_col ]])
216
272
levels <- unique(table [[subset_col ]])
@@ -247,6 +303,15 @@ metafor_object_to_table <- function(rma,
247
303
})
248
304
249
305
subset_table <- do.call(" rbind" , lapply(subset_tables , function (x ) x ))
306
+ } else {
307
+
308
+ levels <- " "
309
+ subset_table <- rbind(
310
+ create_title_row(" " ),
311
+ dplyr :: select(table , Study , est , ci_low , ci_high )
312
+ )
313
+
314
+ }
250
315
251
316
ordered_table <- rbind(subset_table ,
252
317
if (overall_estimate ) {
@@ -266,9 +331,9 @@ metafor_object_to_table <- function(rma,
266
331
267
332
select_rob_columns <- function (dataframe , tool ){
268
333
if (tool == " QUADAS-2" ){
269
- return_data <- select(dataframe , D1 , D2 , D3 , D4 , Overall )
334
+ return_data <- dplyr :: select(dataframe , D1 , D2 , D3 , D4 , Overall )
270
335
}else if (tool == " ROB1" ){
271
- return_data <- select(dataframe ,
336
+ return_data <- dplyr :: select(dataframe ,
272
337
RS = Random.sequence.generation. ,
273
338
A = Allocation.concealment. ,
274
339
BP = Blinding.of.participants.and.personnel. ,
@@ -278,11 +343,11 @@ select_rob_columns <- function(dataframe, tool){
278
343
Oth = Other.sources.of.bias. ,
279
344
Overall = Overall )
280
345
}else if (tool == " ROB2" ){
281
- return_data <- select(dataframe , D1 , D2 , D3 , D4 , D5 , Overall )
346
+ return_data <- dplyr :: select(dataframe , D1 , D2 , D3 , D4 , D5 , Overall )
282
347
}else if (tool == " ROB2-Cluster" ){
283
- return_data <- select(dataframe , D1 , D1b , D2 , D3 , D4 , D5 , Overall )
348
+ return_data <- dplyr :: select(dataframe , D1 , D1b , D2 , D3 , D4 , D5 , Overall )
284
349
}else if (tool == " Robins" ){
285
- return_data <- select(dataframe , D1 , D2 , D3 , D4 , D5 , D6 , D7 , Overall )
350
+ return_data <- dplyr :: select(dataframe , D1 , D2 , D3 , D4 , D5 , D6 , D7 , Overall )
286
351
}else {
287
352
stop(" Tool is not supported." )
288
353
}
0 commit comments