Skip to content

Instantly share code, notes, and snippets.

@chrishanretty
Created February 22, 2014 19:28
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 chrishanretty/9160738 to your computer and use it in GitHub Desktop.
Save chrishanretty/9160738 to your computer and use it in GitHub Desktop.
Irregular changes of leader
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