Skip to content

Instantly share code, notes, and snippets.

@NickCH-K
Created December 6, 2022 22:18
Show Gist options
  • Save NickCH-K/11b0bf38c32f0b0d8faffe6e5f7f0fce to your computer and use it in GitHub Desktop.
Save NickCH-K/11b0bf38c32f0b0d8faffe6e5f7f0fce to your computer and use it in GitHub Desktop.
library(data.table); library(ggplot2)
dat = as.data.table(readxl::read_excel("Polls-per-user-CEU_R_Python_Stata_2022.xlsx"))
dat = dat[2:nrow(dat), 7:8]
setnames(dat, c('After','Before'))
dat = dat[!is.na(Before) & !(Before == 'Other') & !(After == 'Other')]
results = data.table(Language = c('Python','R','Stata'), Change = sapply(c('Python','R','Stata'), \(x) dat[, sum(After == x) - sum(Before == x)]))
ggplot(results, aes(x = Change, y = 0, label = Language)) +
geom_hline(yintercept = 0, size = 1) + geom_point(size = 3, color = 'darkblue') + geom_text(vjust = -1) +
scale_x_continuous(breaks = c(-5, 0, 5, 10), limits = c(-7, 12)) +
ggthemes::theme_economist() +
theme(axis.line = element_blank(), axis.ticks = element_blank(), axis.text.y = element_blank(), axis.title = element_blank(),
panel.grid.major.y = element_blank(), panel.grid.major.x = element_line(colour = "white", size = .75))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment