Created
August 6, 2014 22:17
-
-
Save anonymous/7a9d901280726ce5c8fc to your computer and use it in GitHub Desktop.
R source to import data from the Constituency Level Elections Archive
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
### Configuration variables | |
### | |
clea.names <- c("release","rg","ctr_n", | |
"ctr","yr","mn", | |
"sub","cst_n","cst", | |
"mag","pty_n", "pty", | |
"can","pev1","vot1", | |
"vv1","ivv1","to1", | |
"cv1","cvs1","pv1", | |
"pvs1","pev2","vot2", | |
"vv2","ivv2","to2", | |
"cv2","cvs2","pv2", | |
"pvs2","seat","elec", | |
"ev","count2","count3", | |
"count4","count5","count6", | |
"count7","count8","count9", | |
"count10","count11","count12", | |
"count13","count14","count15", | |
"count16","count17","count18", | |
"count19") | |
clea.widths <- c(1,14,22, | |
4, 4, 4, | |
39, 82, 4, | |
4, 142, 5, | |
98, 8, 8, | |
8, 7, 18, | |
7, 20, 7, | |
20, 6, 6, | |
7, 5, 17, | |
5, 19, 7, | |
20, 4, 4, | |
4, 5, 5, | |
5, 5, 5, | |
5, 5, 5, | |
5, 5, 5, | |
5, 4, 4, | |
4, 4, 4, | |
4) | |
clea.classes <- c("numeric","factor","factor", | |
"numeric","numeric","numeric", | |
"character","character","numeric", | |
"numeric","factor", "numeric", | |
"character","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric", | |
"numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric", | |
"numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric", | |
"numeric","numeric","numeric","numeric","numeric","numeric","numeric") | |
implausible.character <- "^" | |
dat <- read.fwf(file = file("clea_20131204.dat",encoding="latin1"), | |
widths = clea.widths, | |
colClasses= clea.classes, | |
header = FALSE, | |
comment.char = "", | |
sep = implausible.character, | |
col.names =clea.names) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment