Skip to content

Instantly share code, notes, and snippets.

@tts
Created December 19, 2019 07:32
Show Gist options
  • Save tts/1942929657aa89f20a33ffcd15d1fbb5 to your computer and use it in GitHub Desktop.
Save tts/1942929657aa89f20a33ffcd15d1fbb5 to your computer and use it in GitHub Desktop.
2019 Altmetric Top 100 geocoded affiliations on world map
library(tidyverse)
library(readxl)
library(tmaptools)
library(maps)
library(sf)
url <- "https://altmetric.figshare.com/ndownloader/files/20202618"
temp <- tempfile()
download.file(url, temp)
data <- read_excel(temp)
unlink(temp)
data_sep <- data %>%
separate(`Affiliations (GRID)`, paste("org", c("1", "2", "3", "4", "5", "6", "7", "8"), sep = "_"), sep = ";")
aff <- data_sep %>%
select(starts_with("org_")) %>%
gather("key", "value", na.rm = TRUE) %>%
group_by(value) %>%
summarise(Count = n()) %>%
arrange(desc(Count)) %>%
filter(value != "")
aff_geocode <- geocode_OSM(aff$value, as.sf = TRUE)
# Get count for those whose location was found
aff_geocode_count <- left_join(aff_geocode, aff, by = c("query"="value"))
countries_map <- map_data("world")
ggplot() +
geom_map(data = countries_map,
map = countries_map, aes(map_id = region, group = group),
fill = "white", color = "black", size = 0.1) +
scale_size_continuous(range = c(2, 15)) +
geom_sf(data = aff_geocode_count, colour = "sienna2", aes(size = Count), alpha = 0.7) +
theme(axis.title = element_blank(),
axis.text = element_blank(),
axis.ticks = element_blank(),
legend.position = "none",
plot.title = element_text(size = 12*4, color = "#BDBDBD"),
plot.subtitle = element_text(size = 12*2, color = "light grey"),
plot.caption = element_text(size = 12*0.8, color = "#BDBDBD")) +
labs(x = NULL, y = NULL,
title = "2019 Altmetric Top 100",
subtitle = "Affiliations",
caption = "2019 Altmetric Top 100 - dataset.\nhttps://doi.org/10.6084/m9.figshare.11371860.v2")
saveRDS(aff_geocode_count, "altmtop100_aff_geocode.RDS")
ggsave(
"altmtop100world.png",
width = 35,
height = 20,
dpi = 72,
units = "cm",
device = 'png'
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment