Skip to content

Instantly share code, notes, and snippets.

@robwschlegel
Created July 3, 2017 22:18
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 robwschlegel/c511b28c2f4a4460e5a5e5a45da80195 to your computer and use it in GitHub Desktop.
Save robwschlegel/c511b28c2f4a4460e5a5e5a45da80195 to your computer and use it in GitHub Desktop.
# Libraries
library(tidyverse)
library(lubridate)
library(broom)
library(gridExtra)
# President data
data(presidential)
presidential$start <- year(presidential$start)
presidential$end <- year(presidential$end)-1
# Create index of party years
# I couldn't think of a clever automatic way of doing this...
party_year <- data.frame(Year = seq(1953, 2016), Party = c(rep("Republican",8), rep("Democrat",8),
rep("Republican",8), rep("Democrat",4),
rep("Republican",12), rep("Democrat",8),
rep("Republican",8), rep("Democrat",8)))
# Immigration data
green_card <- read_csv("../data/Persons Obtaining Lawful Permanent Resident Status-Fiscal Years 1820 to 2015.csv")
green_card <- merge(green_card, party_year, by = "Year")
removals <- read_csv("../data/Aliens Removed Or Returned-Fiscal Years 1892 To 2015.csv")
removals <- merge(removals, party_year, by = "Year")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment