-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patharticles_map.R
More file actions
57 lines (45 loc) · 1.76 KB
/
articles_map.R
File metadata and controls
57 lines (45 loc) · 1.76 KB
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
library(dplyr)
library(rnaturalearth)
library(rnaturalearthdata)
library(sf)
working_directory
ggtheme_sf_plot()
## Africa Map - Articles
africa_map <- rnaturalearth::ne_countries(scale = 110, returnclass = "sf", continent = "africa")
print(st_is_valid(africa_map)) #st valid for Sudan is false
articles_map <- sapply(c("depression", "anxiety", "psychosis"), function(x){
nn <- x
df <- df_quality %>%
dplyr::filter(.data[[nn]] == "Yes") %>%
dplyr::group_by(study_country) %>%
count() %>%
ungroup() %>%
dplyr::mutate(study_country2 = study_country)
map_df <- africa_map %>%
dplyr::left_join(df,
by = c("geounit" = "study_country")
)
plot <- ggplot(data = map_df) +
geom_sf(aes(colour= paste0("No ", nn, " Articles")) , fill = "grey") +
geom_sf(aes(fill = study_country2), show.legend = FALSE) +
geom_sf_text(aes(label = study_country2), size = 2.5, colour = "black",
nudge_x = 0, nudge_y = -1.5, fontface = "bold"
) +
stat_sf_coordinates(aes(size = n), colour = "black") +
scale_colour_manual(name="",
breaks=c(paste0("No ", nn, " Articles")),
values = NA
)+
scale_fill_discrete(na.translate=FALSE) +
labs(title = "", x = "", y = "", size = "No. of Articles", fill = "Countries") +
guides(colour=guide_legend("", override.aes=list( colour = "grey", fill = "grey"))
)
}, simplify = FALSE
)
print(articles_map)
## Saving the articles map plots
for (j in seq(length(articles_map))) {
ggsave(plot=articles_map[[j]], height = 6, width = 7,
filename = paste0("articles_plot_",names(articles_map)[j],".png"),
path = output_Dir, bg='white')
}