Skip to content

Commit f832991

Browse files
committed
Upload
1 parent 9e3c32e commit f832991

12 files changed

+74
-115
lines changed

R/rob_summary_plot.R

+18-30
Original file line numberDiff line numberDiff line change
@@ -7,50 +7,36 @@
77
#' @export
88

99
rob_summary <- function(data, tool, save = "No") {
10-
#End column depends on number of domains in tool (end <- no. of domains + 1)
11-
if (tool == "ROBINS-I") {
12-
end <- 8
13-
}
14-
if (tool == "QUADAS-2") {
15-
end <- 5
16-
}
1710

1811
if (tool == "ROB2") {
19-
start <- 2
20-
end <- 6
2112
data.tmp <- data
2213
print("Renaming columns...")
2314
names(data.tmp)[2] <- "Bias due to randomisation"
2415
names(data.tmp)[3] <- "Bias due to deviations from intended intervention"
2516
names(data.tmp)[4] <- "Bias due to missing data"
2617
names(data.tmp)[5] <- "Bias due to outcome measurement"
2718
names(data.tmp)[6] <- "Bias due to selection of reported result"
19+
names(data.tmp)[7] <- "Weight"
20+
data.tmp <- data.tmp[,c(2:7)]
2821

2922
rob.tidy <- suppressWarnings(tidyr::gather(data.tmp,
3023
domain, judgement,
31-
start:end))
32-
print("Data tidied")
24+
-Weight))
3325

34-
# rob.tidy <-
26+
print("Data tidied")
3527

3628
rob.tidy$judgement <- as.factor(rob.tidy$judgement)
3729
rob.tidy$domain <- as.factor(rob.tidy$domain)
3830

39-
# rob.tidy$domain <- as.factor(rob.tidy$domain)
40-
41-
# rob.tidy$domain <- factor(rob.tidy$domain,
42-
# levels(rob.tidy$domain)[c(5, 2, 3, 1, 4)])
43-
4431
rob.tidy$domain <- factor(rob.tidy$domain,
45-
levels(rob.tidy$domain)[c(5, 2, 3, 1, 4)])
46-
32+
levels(rob.tidy$domain)[c(5, 3, 2, 1, 4)])
4733

4834
rob.tidy$judgement <- factor(rob.tidy$judgement,
4935
levels(rob.tidy$judgement)[c(1, 3, 2)])
5036

5137
plot <- ggplot2::ggplot(data = rob.tidy) +
5238
geom_bar(
53-
mapping = aes(x = domain, fill = judgement),
39+
mapping = aes(x = domain, fill = judgement,weight = Weight),
5440
width = 0.7,
5541
position = "fill",
5642
color = "black"
@@ -93,7 +79,7 @@ if (tool == "ROB2") {
9379

9480
if (tool == "ROBINS-I") {
9581
start <- 2
96-
end <- 8
82+
end <- 9
9783
data.tmp <- data
9884
print("Renaming columns...")
9985
names(data.tmp)[2] <- "Bias due to confounding"
@@ -106,8 +92,8 @@ if (tool == "ROBINS-I") {
10692

10793
rob.tidy <- suppressWarnings(tidyr::gather(data.tmp,
10894
domain, judgement,
109-
start:end))
110-
95+
start:end,
96+
-Weight))
11197
print("Data tidied")
11298

11399
rob.tidy$judgement <- as.factor(rob.tidy$judgement)
@@ -169,7 +155,7 @@ if (tool == "ROBINS-I") {
169155

170156
if (tool == "QUADAS-2") {
171157
start <- 2
172-
end <- 5
158+
end <- 6
173159
data.tmp <- data
174160
print("Renaming columns...")
175161
names(data.tmp)[2] <- "Patient selection"
@@ -179,7 +165,8 @@ if (tool == "QUADAS-2") {
179165

180166
rob.tidy <- suppressWarnings(tidyr::gather(data.tmp,
181167
domain, judgement,
182-
start:end))
168+
start:end,
169+
-Weight))
183170
print("Data tidied")
184171

185172
rob.tidy$judgement <- as.factor(rob.tidy$judgement)
@@ -204,13 +191,14 @@ if (tool == "QUADAS-2") {
204191
scale_fill_manual(
205192
"Risk of Bias",
206193
values = c(
207-
"Low" = "#66c2a5",
194+
"High" = "#fc8d62",
208195
"Some concerns" = "#808080",
209-
"High" = "#fc8d62"
196+
"Low" = "#66c2a5"
210197
),
211-
labels = c(" Low risk of bias ",
212-
" Some concerns ",
213-
" High risk of bias ")
198+
labels = c(
199+
" High risk of bias ",
200+
" Some concerns ",
201+
" Low risk of bias ")
214202
) +
215203
scale_y_continuous(labels = scales::percent) +
216204
theme(

R/traffic_light_plot.R

-37
This file was deleted.

data/data_quadas.csv

-13
This file was deleted.

data/data_quadas.rda

421 Bytes
Binary file not shown.

data/data_rob.csv

-13
This file was deleted.

data/data_rob.rda

407 Bytes
Binary file not shown.

data/data_robins.csv

-13
This file was deleted.

data/data_robins.rda

493 Bytes
Binary file not shown.

data_raw/data_quadas.csv

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Study,D1,D2,D3,D4,Weight
2+
Study 1,Low,Low,Low,Low,33.33333333
3+
Study 2,Some concerns,Low,Low,Low,33.33333333
4+
Study 3,Some concerns,Low,Some concerns,Low,0.142857143
5+
Study 4,Low,Low,High,Low,9.090909091
6+
Study 5,High,High,Low,Low,12.5
7+
Study 6,Low,High,Some concerns,Low,25
8+
Study 7,Low,Some concerns,Some concerns,High,200
9+
Study 8,Low,Some concerns,Low,Low,11.11111111
10+
Study 9,Low,Low,High,Low,1.111111111
11+
Study 10,Some concerns,Low,Low,High,33.33333333
12+
Study 11,Some concerns,High,Some concerns,Low,0.142857143
13+
Study 12,Low,Low,Low,Low,9.090909091

data_raw/data_rob.csv

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Study,D1,D2,D3,D4,D5,Weight
2+
Study 1,Low,Low,Low,Low,Low,33.33333333
3+
Study 2,Some concerns,Low,Low,Low,Low,33.33333333
4+
Study 3,Some concerns,Low,Some concerns,Low,Low,0.142857143
5+
Study 4,Low,Low,High,Low,Some concerns,9.090909091
6+
Study 5,High,High,Low,Low,Some concerns,12.5
7+
Study 6,Low,High,Some concerns,Low,Low,25
8+
Study 7,Low,Some concerns,Some concerns,High,Low,200
9+
Study 8,Low,Some concerns,Low,Low,Low,11.11111111
10+
Study 9,Low,Low,High,Low,Low,1.111111111

data_raw/data_robins.csv

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Study,D1,D2,D3,D4,D5,D6,D7,Weight
2+
Study 1,Critical,Low,Critical,Critical,Low,Low,High,33.33333333
3+
Study 2,Some concerns,Low,Low,Critical,Low,Some concerns,Low,33.33333333
4+
Study 3,Some concerns,Low,Some concerns,Critical,Critical,Low,High,0.142857143
5+
Study 4,Low,Low,High,Critical,Some concerns,Low,Critical,9.090909091
6+
Study 5,High,High,Low,Low,Some concerns,Low,Some concerns,12.5
7+
Study 6,Critical,High,Some concerns,Critical,Critical,Some concerns,High,25
8+
Study 7,Critical,Some concerns,Some concerns,High,Critical,High,High,200
9+
Study 8,Critical,Some concerns,Low,Low,Low,Low,Critical,11.11111111
10+
Study 9,Critical,Low,High,Low,Low,High,Low,1.111111111
11+
Study 10,Some concerns,Low,Critical,High,Some concerns,Some concerns,High,0.142857143
12+
Study 11,Some concerns,High,Some concerns,Critical,High,Low,Critical,9.090909091
13+
Study 12,Critical,Critical,Low,Critical,Critical,Critical,Critical,12.5

vignettes/Introduction to robvis.Rmd

+20-9
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,31 @@ knitr::opts_chunk$set(
1414
comment = "#>",
1515
warning = FALSE,
1616
fig.width = 8,
17-
fig.height = 2.41,
17+
fig.height = 2.41)
1818
library(tidyverse)
19-
)
19+
library(robvis)
2020
```
2121
## R Markdown
2222

23-
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
2423

25-
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
2624

27-
```{r robsummary}
28-
#Import data
29-
data_rob <- read.csv("../data/data_rob.csv", header = TRUE)
25+
```{r rob2summary}
26+
#Import data for ROB2.0 based risk-of-bias assessments
3027
31-
# Produce summary barchart, detailing % of included studies that were at a given risk of bias for a certain domain of the RoB2.0 tool.
32-
robvis::rob_summary(data_rob, tool = "ROB2", save = "No")
28+
# Produce barchart summarising risk of bias for each domain, weighted by study precision.
29+
robvis::rob_summary(robvis::data_rob, tool = "ROB2", save = "No")
30+
```
31+
32+
Users can also produce summary plots for two other commonly used tools: ROBINS-I and QUADAS-2
33+
34+
```{r robinssummary}
35+
#Import data for ROB2.0 based risk-of-bias assessments
36+
# Produce barchart summarising risk of bias for each domain, weighted by study precision.
37+
robvis::rob_summary(data_robins, tool = "ROBINS-I", save = "No")
38+
```
39+
40+
```{r quadassummary}
41+
#Import data for ROB2.0 based risk-of-bias assessments
42+
# Produce barchart summarising risk of bias for each domain, weighted by study precision.
43+
robvis::rob_summary(data_quadas, tool = "QUADAS-2", save = "No")
3344
```

0 commit comments

Comments
 (0)