# There is quite a bit to install, it takes quite a while compilling
if(F) {
install.packages(c("cowplot", "googleway", "ggplot2", "ggrepel",
"ggspatial", "libwgeom", "sf", "rnaturalearth", "rnaturalearthdata")
)
install.packages("rgeos")
}
library("ggplot2")
theme_set(theme_bw())
library("sf")
library("rnaturalearth")
library("rnaturalearthdata")
library("rgeos")
world <- ne_countries(scale = "medium", returnclass = "sf")
head(world)
## From paper https://datadryad.org/stash/dataset/doi:10.5061/dryad.q447c
## Crunched by https://thewinnower.com/papers/4715-correlating-the-sci-hub-data-with-world-bank-indicators-and-identifying-academic-use
downloads <- read.table("https://raw.githubusercontent.com/gedankenstuecke/scihub_analysis/master/downloads_country.csv", quote="", sep = "\t", header = T, fill = T)
world$downloads <- downloads[match(world$name, trimws(as.character(downloads$Country))),"Downloads"]
# Debug missing countries
downloads[grepl("Croatia", downloads$Country),]
world[grepl("orea", world$name),"downloads"]
world[world$name == "Czech Rep.",]
# and fix them
world[world$name == "Korea","downloads"] <- downloads[grepl("Korea", downloads$Country),"Downloads"]
world[world$name == "Myanmar","downloads"] <- downloads[grepl("Myanmar", downloads$Country),"Downloads"]
world[world$name == "Czech Rep.","downloads"] <- downloads[grepl("Czech", downloads$Country),"Downloads"]
world$by_pop <- world$downloads / world$pop_est
world$Value <- world$downloads
png("first_go.png", width = 1900, height = 900)
ggplot(data = world) +
geom_sf(aes(fill = Value), show.legend = NA) +
scale_fill_viridis_c(option = "plasma", trans = "sqrt")
dev.off()
png("by_pop.png", width = 1900, height = 900)
ggplot(data = world) +
geom_sf(aes(fill = by_pop), show.legend = NA) +
scale_fill_viridis_c(option = "plasma", trans = "sqrt")
dev.off()