Created
June 27, 2016 15:42
-
-
Save mw55309/13da06ba8a1bd114e56671911325568b to your computer and use it in GitHub Desktop.
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
d <- read.csv("http://www.electoralcommission.org.uk/__data/assets/file/0014/212135/EU-referendum-result-data.csv") | |
vec <- rep(1, nrow(d)) | |
vec[d$Region=="Scotland"] <- 1 | |
vec[d$Region=="North East"] <- 2 | |
vec[d$Region=="North West"] <- 3 | |
vec[d$Region=="East Midlands"] <- 4 | |
vec[d$Region=="West Midlands"] <- 5 | |
vec[d$Region=="Yorkshire and The Humber"] <- 6 | |
vec[d$Region=="Northern Ireland"] <- 7 | |
vec[d$Region=="Wales"] <- 8 | |
vec[d$Region=="East"] <- 9 | |
vec[d$Region=="London"] <- 10 | |
vec[d$Region=="South East"] <- 11 | |
vec[d$Region=="South West"] <- 12 | |
order <- as.factor(vec) | |
nd <- cbind(d, order) | |
levels(nd$order) <- c("Scotland","North East","North West","East Midlands","West Midlands","Yorkshire and The Humber","Northern Ireland","Wales","East","London","South East","South West") | |
nd$prop <- log2(nd$Leave / nd$Remain) | |
nd$perc <- (nd$Leave / (nd$Leave + nd$Remain)) * 100 | |
par(mar=c(4,12,2,2)) | |
boxplot(perc ~ order, data=nd, las=2, horizontal=TRUE, ylim=c(0,100)) | |
abline(v = 50, col = "red", lty=3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment