Skip to content

Instantly share code, notes, and snippets.

@ikashnitsky
Last active February 10, 2022 17:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ikashnitsky/2b3745141f57d4b57a3d9c77a73b75ee to your computer and use it in GitHub Desktop.
Save ikashnitsky/2b3745141f57d4b57a3d9c77a73b75ee to your computer and use it in GitHub Desktop.
Evolution acceptance and vaccination – https://twitter.com/ikashnitsky/status/1491829028667416578
#===============================================================================
# 2022-02-10 -- twitter
# Digitize data from: Miller, J. D., Scott, E. C., & Okamoto, S. (2006). Public Acceptance of Evolution. Science. https://doi.org/10.1126/science.1126746
# Ilya Kashnitsky, ilya.kashnitsky@gmail.com, @ikashnitsky
#===============================================================================
library(tidyverse)
library(magrittr)
library(hrbrthemes)
library(countrycode)
library(lubridate)
library(ggrepel)
# # copy ordered countries names from the paper (manual fixing for two words names)
# a <- c("Iceland", "500)", "Denmark", "(1013)", "Sweden", "(1023)", "France", "(1021)", "Japan", "(2146)", "United Kingdom", "(1308)", "Norway", "(976)", "Belgium", "(1024)", "Spain", "(1035)", "Germany", "(1507)", "Italy", "(1006)", "Netherlands", "(1005)", "Hungary", "(1000)", "Luxembourg", "(518)", "Ireland", "(1008)", "Slovenia", "(1061)", "Finland", "(1006)", "Czech Republic", "(1037)", "Estonia", "(1000)", "Portugal", "(1009)", "Malta", "(500)", "Switzerland", "(999)", "Slovak Republic", "(1241)", "Poland", "(999)", "Austria", "(1034)", "Croatia", "(1000)", "Romania", "(1005)", "Greece", "(1000)", "Bulgaria", "(1008)", "Lithuania", "(1003)", "Latvia", "(1034)", "Cyprus", "(505)", "United States", "(1484)", "Turkey", "(1005")
#
# # take out only every second
# b <- a[seq(1, 67, 2)]
#
# # now digitize
# library(digitize)
# p <- digitize("~/Downloads/fig-1.png") # note: here is a path to a local screenshot
# # next goes manual digitizing of the data, see my results here:
# # https://twitter.com/ikashnitsky/status/1491831174217535488
#
# # put everything together
# evol <- tibble(
# country = b,
# evol_agree = p$x %>% rev
# ) %>%
# mutate(iso_code = countrycode(country, origin = "country.name", destination = "iso3c"))
# read back the output of this manual data digitizing
evol <- read_csv("https://gist.githubusercontent.com/ikashnitsky/2b3745141f57d4b57a3d9c77a73b75ee/raw/b72ed6a635f75354af2e248604f2b5a11d7f9698/out-data.csv")
# vaccination data from OWD
# read from a local copy of the public dataset from
# https://covid.ourworldindata.org/data/owid-covid-data.csv
owd <- read.csv("~/data/owd/owid-covid-data.csv.gz")
vac <- owd %>%
filter(year(date) == "2021") %>%
group_by(iso_code, location) %>%
summarise(
vac_int = people_fully_vaccinated_per_hundred %>% divide_by(100) %>% mean(na.rm = T),
vac_int_w = new_cases_per_million %>% prop.table %>%
multiply_by(people_fully_vaccinated_per_hundred %>% divide_by(100)) %>% sum(na.rm = T),
pop = population %>% mean
)
# patch LUX - people vaccinated
lux <- owd %>%
filter(year(date) == "2021", iso_code == "LUX") %>%
group_by(iso_code, location) %>%
summarise(
vac_int = people_vaccinated_per_hundred %>% divide_by(100) %>% mean(na.rm = T),
vac_int_w = new_cases_per_million %>% prop.table %>%
multiply_by(people_vaccinated_per_hundred %>% divide_by(100)) %>% sum(na.rm = T),
pop = population %>% mean
)
vax <- vac %>% filter(!iso_code == "LUX") %>% bind_rows(lux)
df <- evol %>% left_join(vax)
# plot
df %>%
ggplot(aes(evol_agree, vac_int))+
geom_text_repel(
aes(label = iso_code), size = 2, color = "#bababa",
family = font_rc
)+
geom_point(color = 1, aes(size = pop))+
scale_x_continuous(limits = c(20, NA), position = "top") +
scale_y_continuous(limits = c(0, NA)) +
theme_minimal(base_family = font_rc)+
theme(plot.background = element_rect(color = NA, fill = "#fafafa"))+
theme(
legend.position = "none",
plot.title = element_text(family = "Roboto Slab", face = 2),
panel.grid.minor = element_blank()
)+
labs(
y = "Integral vaccination measure [0, 1]",
x = "Proportion accepting evolution",
caption = "Data: Miller etal 2006; OWD // Design: @ikashnitsky",
title = "Accepting evolution is associated with higher vaccine uptake"
)
ggsave("~/Downloads/evolution-and-vaccination.png", width = 6.4, height = 3.6, type = "cairo-png")
country evol_agree iso_code
Iceland 84.64285714285711 ISL
Denmark 82.14285714285711 DNK
Sweden 81.78571428571428 SWE
France 80.35714285714283 FRA
Japan 77.85714285714283 JPN
United Kingdom 75.35714285714283 GBR
Norway 73.57142857142856 NOR
Belgium 73.2142857142857 BEL
Spain 73.2142857142857 ESP
Germany 71.78571428571425 DEU
Italy 69.28571428571428 ITA
Netherlands 68.21428571428572 NLD
Hungary 66.78571428571428 HUN
Luxembourg 66.78571428571428 LUX
Ireland 66.78571428571428 IRL
Slovenia 66.42857142857139 SVN
Finland 65.35714285714286 FIN
Czech Republic 66.42857142857139 CZE
Estonia 63.92857142857144 EST
Portugal 63.92857142857144 PRT
Malta 62.14285714285712 MLT
Switzerland 62.14285714285712 CHE
Slovak Republic 58.57142857142858 SVK
Poland 57.85714285714284 POL
Austria 57.49999999999999 AUT
Croatia 57.49999999999999 HRV
Romania 54.642857142857146 ROU
Greece 53.92857142857141 GRC
Bulgaria 49.64285714285713 BGR
Lithuania 49.64285714285713 LTU
Latvia 47.85714285714284 LVA
Cyprus 46.42857142857141 CYP
United States 40.357142857142854 USA
Turkey 26.78571428571427 TUR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment