Skip to content

Commit 65737f1

Browse files
committed
[Expect failing tests]
1 parent c49e78f commit 65737f1

File tree

13 files changed

+128
-20
lines changed

13 files changed

+128
-20
lines changed

.Rbuildignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
^CONTRIBUTING\.md$
1717
^JOSS-paper$
1818
^RSM-paper$
19-
R/rob_blobbogram.R
2019
cran-comments.md
2120
^CRAN-RELEASE$
2221
^_pkgdown\.yml$

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,3 @@ docs/
1010
*.jpeg
1111
/*.png
1212
*.xlsx
13-
R/rob_paired_plot.R

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
export(rob_append_to_forest)
44
export(rob_append_weights)
5+
export(rob_blobbogram)
56
export(rob_save)
67
export(rob_summary)
78
export(rob_tools)

R/rob_blobbogram.R

Lines changed: 82 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,51 @@ rob_blobbogram <- function(rma,
2929
add_tests = TRUE,
3030
...){
3131

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+
3277
data <- metafor_object_to_table(rma,
3378
rob,
3479
subset_col = subset_col,
@@ -41,14 +86,23 @@ rob_blobbogram <- function(rma,
4186
rob_plot <- select_rob_columns(data, rob_tool) %>%
4287
appendable_rob_ggplot(rob_tool = rob_tool,
4388
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+
))
52106

53107
}
54108

@@ -111,7 +165,7 @@ create_title_row <- function(title){
111165
return(data.frame(Study = title, est = NA, ci_low = NA, ci_high = NA))
112166
}
113167

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"){
115169
# given a data frame with arbitrary column names, makes a rob plot with those columns
116170
# when space_last = true, separates the last column by a half width (usually for an overall)
117171
# NA rows indicate spaces
@@ -134,7 +188,7 @@ appendable_rob_ggplot <- function(rob_gdata, space_last = TRUE, rob_tool = "ROB2
134188

135189
rob_colours <- get_colour(rob_tool, rob_colour)
136190

137-
if(rob_tool == "Robins"){
191+
if(rob_tool == "ROBINS-I"){
138192
bias_colours <- c("Critical" = rob_colours$critical_colour,
139193
"Serious" = rob_colours$high_colour,
140194
"Moderate" = rob_colours$concerns_colour,
@@ -167,12 +221,12 @@ appendable_rob_ggplot <- function(rob_gdata, space_last = TRUE, rob_tool = "ROB2
167221
xmax = .data$xmax,
168222
ymax = .data$ymax),
169223
fill = "white",
170-
colour = "#eff3f2") +
224+
colour = "#a9a9a9") +
171225
ggplot2::geom_point(size = 5, ggplot2::aes(x = .data$x, y = .data$row_num, colour = .data$colour)) +
172226
ggplot2::geom_point(size = 3, ggplot2::aes(x = .data$x, y = .data$row_num, shape = .data$colour)) +
173227
ggplot2::scale_y_continuous(expand = c(0,0)) + # position dots
174228
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") +
176230
ggplot2::scale_color_manual(values = bias_colours,
177231
na.translate = FALSE) +
178232
ggplot2::scale_shape_manual(
@@ -211,6 +265,8 @@ metafor_object_to_table <- function(rma,
211265
# Reorder data
212266
table <- dplyr::select(table, Study, dplyr::everything())
213267

268+
if (!is.null(subset_col)) {
269+
214270
# Clean level names so that they look nice in the table
215271
table[[subset_col]] <- stringr::str_to_sentence(table[[subset_col]])
216272
levels <- unique(table[[subset_col]])
@@ -247,6 +303,15 @@ metafor_object_to_table <- function(rma,
247303
})
248304

249305
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+
}
250315

251316
ordered_table <- rbind(subset_table,
252317
if (overall_estimate) {
@@ -266,9 +331,9 @@ metafor_object_to_table <- function(rma,
266331

267332
select_rob_columns <- function(dataframe, tool){
268333
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)
270335
}else if(tool == "ROB1"){
271-
return_data <- select(dataframe,
336+
return_data <- dplyr::select(dataframe,
272337
RS = Random.sequence.generation.,
273338
A = Allocation.concealment.,
274339
BP = Blinding.of.participants.and.personnel.,
@@ -278,11 +343,11 @@ select_rob_columns <- function(dataframe, tool){
278343
Oth = Other.sources.of.bias.,
279344
Overall = Overall)
280345
}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)
282347
}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)
284349
}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)
286351
}else{
287352
stop("Tool is not supported.")
288353
}

man/rob_blobbogram.Rd

Lines changed: 44 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/Rplots.pdf

0 Bytes
Binary file not shown.
484 KB
Loading
484 KB
Loading
484 KB
Loading
484 KB
Loading

0 commit comments

Comments
 (0)