Skip to content

Instantly share code, notes, and snippets.

@ajsteele
ajsteele / gdpPerCapitaComparisons.R
Created April 29, 2024 17:19
A few graphs of population-corrected GDP metrics in response to this much-retweeted tweet dunking on Europe’s tech prowess: https://twitter.com/levelsio/status/1784943280171467260
library(wbstats)
library(tidyverse)
library(ggplot2)
library(devtools)
install_github("Financial-Times/ftplottools")
library(ftplottools)
gdp_pc <-
wb_data(
indicator = c('SP.POP.TOTL', 'NY.GDP.PCAP.PP.KD', 'NY.GDP.PCAP.KD.ZG'),
@ajsteele
ajsteele / expected-return-on-vote-eu-referendum-2016.R
Created June 23, 2016 12:46
A calculation of the expected return on a vote to remain in the EU referendum
# Calculating the expected return on a vote for the UK to
# remain a member of the European Union.
# v1.0
# CC0 Andrew Steele (@statto)
# What are the odds of the election being won by your vote?
voters = 45e6 * 2/3 # 45 million voters, 2/3 turnout
diff(
pnorm(
voters/2 + 0:1, # victory by one vote