Created
February 22, 2014 19:28
-
-
Save chrishanretty/9160738 to your computer and use it in GitHub Desktop.
Irregular changes of leader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(foreign) | |
library(gdata) | |
### Load archigos data | |
### from http://www.rochester.edu/college/faculty/hgoemans/data.htm | |
archi <- read.dta("Archigos_2.9-Public.dta") | |
### Only `irregular' leader transitions with popular support | |
### with or without foreign support | |
archi <- subset(archi,exit==3 & exitcode %in% c(1,2)) | |
### Handle dates properly | |
archi$enddate <- as.Date(archi$enddate,"%d/%m/%Y") | |
archi$endyear <- format(archi$enddate,"%Y") | |
### Merge with Polity scores | |
### from http://www.systemicpeace.org/inscr/inscr.htm | |
polity <- read.xls("p4v2012.xls",sheet=1) | |
archi <- merge(archi,polity, | |
all.x=T,all.y=F, | |
by.x = c("ccode","endyear"), | |
by.y = c("ccode","year")) | |
archi$plot.text <- paste(archi$idacr," (",archi$endyear, ": ", archi$leader,")",sep="") | |
### Get rid of missings | |
archi$polity[which(archi$polity < -10)] <- NA | |
archi <- subset(archi,!is.na(polity)) | |
plot.df <- archi[order(archi$polity),c("plot.text","polity")] | |
plot.df <- rbind(plot.df, | |
data.frame(plot.text = "UKR 2014 (Yanukovych)",polity = 6)) | |
png(file="irregular.png",width=600,height=800) | |
dotchart(plot.df$polity,labels = plot.df$plot.text, | |
pch = 19, | |
col = c(rep("black",nrow(plot.df)-1),"red"), | |
xlab = "Polity score (10 = wholly democratic)") | |
dev.off() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment