Created
September 18, 2012 04:21
-
-
Save jstray/3741250 to your computer and use it in GitHub Desktop.
Load in the UK house of Lords data
This file contains hidden or 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(proxy) # need custom distance function capability | |
# -------------------------------- Load data ------------------------------ | |
# Load in vote history | |
# strip out vote description, date, etc, and transpose so each row is an MP | |
votetable = read.csv("votematrix-lords.csv", header=T, sep=",") | |
votes = votetable[, 5:1047] | |
votes = t(votes) | |
# Load Lord descriptions, and order by MPID, which is the column ordering in votes | |
lords = read.csv("lords.csv", header=T, sep=",") | |
lords = lords[order(lords[,"mpid"]),] | |
# Turn "aye" (encoded as 2) into +1, and "nay" (encoded as 4) into -1, all else zero | |
ayes <- votes == 2 | |
nays <- votes == 4 | |
votes <- array(0, dim(votes)) | |
votes[ayes] <- 1 | |
votes[nays] <- -1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment