-
Notifications
You must be signed in to change notification settings - Fork 1
/
egm.R
60 lines (51 loc) · 2.07 KB
/
egm.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Load packages
library(readxl)
library(ggplot2)
library(dplyr)
library(tidyr)
library(colorspace)
# Extract the data
panda <- read_excel("panda.xlsx")
# View the data
View(panda)
# Tile
tile <- panda %>%
group_by(intervention, outcome) %>%
summarise(count_author_year_tile = n(), .groups = 'drop') %>%
complete(intervention, outcome, fill = list(count_author_year_tile = 0))
# Bubble
bubble <- panda %>%
group_by(intervention, outcome, study_design) %>%
summarise(count_author_year_bubble = n(), .groups = 'drop') %>%
filter(!is.na(study_design))
# Evidence gap map
egm <- ggplot(tile, aes(x = outcome, y = intervention)) +
geom_tile(aes(fill = count_author_year_tile), color = "black") +
geom_point(data = bubble, aes(size = count_author_year_bubble, color = study_design),
alpha = 0.6, position = position_jitterdodge(jitter.width = 0.2,
dodge.width = 0.5, seed = 6554)) +
scale_size_continuous(range = c(3, 10),
breaks = c(1, 3, 5, 10, 20),
labels = function(x) round(x, 0)) +
scale_colour_discrete_qualitative() +
scale_fill_gradient(low = "white", high = "steelblue") +
labs(title = "Evidence gap map",
x = "Health-related outcomes",
y = "Diet intake intervention",
fill = "Total studies",
size = "Number of studies per study design",
color = "Study design") +
theme_minimal() +
theme(plot.title = element_text(hjust = 0.5),
axis.text.x = element_text(size = 12, angle = 45, hjust = 1),
axis.text.y = element_text(size = 12),
legend.position = "bottom",
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),) +
guides(size = guide_legend(nrow = 2,
title = "Number of studies\nper study design"),
colour = guide_legend(nrow = 3, override.aes = list(size = 5)))
egm
# Save as a picture file
ggsave("egm.jpg", plot = egm,
width = 15, height = 10, dpi = 300)