Skip to content

Instantly share code, notes, and snippets.

@svmiller
Last active May 23, 2017 23:42
Show Gist options
  • Save svmiller/68c95dbde4d3d2af1aa86f3b8c437ae6 to your computer and use it in GitHub Desktop.
Save svmiller/68c95dbde4d3d2af1aa86f3b8c437ae6 to your computer and use it in GitHub Desktop.
Convert CoW state data to country-year panel data.
library(tidyverse)
States <- read_csv("~/Dropbox/data/COW/states/states2011.csv")
# Create a PDF of state-years. ----------
# States data nominally end in 2011, so let's fudge that.
States %>%
mutate(endyear = ifelse(endyear == 2011, 2015, endyear)) %>%
rowwise() %>%
mutate(year = list(seq(styear, endyear))) %>%
ungroup() %>%
unnest() %>%
arrange(ccode, year) %>%
select(ccode, year) %>%
distinct(ccode, year) -> CYs
CYs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment