Skip to content

Instantly share code, notes, and snippets.

@ritchieking
ritchieking / data.csv
Last active December 15, 2015 03:39
The growth in catholics around the world
country diff
Mexico 11048128
Philippines 9671495
Congo DR 8740279
United States 7685824
Brazil 7187750
Nigeria 5667679
Colombia 4909147
Spain 4136959
Uganda 3441907
@ritchieking
ritchieking / data.tsv
Last active January 3, 2016 18:39
Line chart, with comments
year lifeExpectancy
1/1/1961 53.00618814
1/1/1962 53.49544588
1/1/1963 54.14244036
1/1/1964 54.97746907
1/1/1965 55.82684751
1/1/1966 56.74868644
1/1/1967 57.61738778
1/1/1968 58.33389775
1/1/1969 59.00507154
@ritchieking
ritchieking / data.tsv
Last active January 3, 2016 18:59
Line chart, clean
1/1/1961 53.00618814
1/1/1962 53.49544588
1/1/1963 54.14244036
1/1/1964 54.97746907
1/1/1965 55.82684751
1/1/1966 56.74868644
1/1/1967 57.61738778
1/1/1968 58.33389775
1/1/1969 59.00507154
@ritchieking
ritchieking / data.csv
Last active January 4, 2016 08:59
Income per capita in poor countries
Country year value group
Benin 1962 90 low-income
Burkina Faso 1962 80 low-income
Burundi 1962 70 low-income
Cen. African Rep. 1962 80 low-income
Chad 1962 110 low-income
Congo, Dem. Rep. 1962 230 low-income
Kenya 1962 100 low-income
Liberia 1962 160 low-income
Madagascar 1962 130 low-income
Malawi 1962 50 low-income
Nepal 1962 60 low-income
Niger 1962 150 low-income
Rwanda 1962 40 low-income
Togo 1962 90 low-income
Zimbabwe 1962 270 low-income
Benin 1963 100 low-income
Burkina Faso 1963 80 low-income
Burundi 1963 80 low-income
Cen. African Rep. 1963 80 low-income
Chad 1963 110 low-income
Congo, Dem. Rep. 1963 270 low-income
Kenya 1963 100 low-income
Liberia 1963 160 low-income
Madagascar 1963 130 low-income
Malawi 1963 50 low-income
Nepal 1963 50 low-income
Niger 1963 160 low-income
Rwanda 1963 40 low-income
Togo 1963 90 low-income
Zimbabwe 1963 280 low-income
Benin 1964 110 low-income
Burkina Faso 1964 80 low-income
Burundi 1964 80 low-income
Cen. African Rep. 1964 80 low-income
Chad 1964 110 low-income
@ritchieking
ritchieking / data.csv
Last active January 4, 2016 13:29
Income per capita in poor countries, the interactive version
Benin 1962 90 low-income
Burkina Faso 1962 80 low-income
Burundi 1962 70 low-income
Cen. African Rep. 1962 80 low-income
Chad 1962 110 low-income
Congo, Dem. Rep. 1962 230 low-income
Kenya 1962 100 low-income
Liberia 1962 160 low-income
Madagascar 1962 130 low-income
Malawi 1962 50 low-income
Nepal 1962 60 low-income
Niger 1962 150 low-income
Rwanda 1962 40 low-income
Togo 1962 90 low-income
Zimbabwe 1962 270 low-income
Benin 1963 100 low-income
Burkina Faso 1963 80 low-income
Burundi 1963 80 low-income
Cen. African Rep. 1963 80 low-income
Chad 1963 110 low-income
Congo, Dem. Rep. 1963 270 low-income
Kenya 1963 100 low-income
Liberia 1963 160 low-income
Madagascar 1963 130 low-income
Malawi 1963 50 low-income
Nepal 1963 50 low-income
Niger 1963 160 low-income
Rwanda 1963 40 low-income
Togo 1963 90 low-income
Zimbabwe 1963 280 low-income
Benin 1964 110 low-income
Burkina Faso 1964 80 low-income
Burundi 1964 80 low-income
Cen. African Rep. 1964 80 low-income
Chad 1964 110 low-income
@ritchieking
ritchieking / README.md
Last active August 29, 2015 14:18
Philly Emerging Tech: Visual Storytelling with D3
<style type="text/css"> img { width: 700px; margin: 50px 0 50px 0; } </style>

Ritchie King

Visual Journalist, FiveThirtyEight

@ritchieking
ritchieking / README.md
Created April 29, 2016 17:17
fresh block
@ritchieking
ritchieking / README.md
Created April 29, 2016 20:57
Axis formats based on width
@ritchieking
ritchieking / fetchGHdata.R
Created June 6, 2018 23:48
Fetch a data file directly from a private GitHub repo in R
# Download any data file from a private GitHub repo
# regardless of how large it is.
# Returns a string that will then need to be parsed
# by read_csv or the like to turn it into a data frame.
# Dependencies
require(tidyverse)
require(httr)
require(rlist)
require(jsonlite)
@ritchieking
ritchieking / readme.md
Created June 15, 2018 18:31
Require R packages from a vector of package names; install a package automatically if it's not installed

This might be a terrible idea, but I like loading packages without a bunch of a require statements — or needing to explicitly install a package if I haven't already done so. I have this function in my .Rprofile, so the top of my R files look like this:

pkgs <- c(
  "tidyverse",
  "Hmisc",
  ... etc.
)

smartRequire(pkgs)