You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This past June, the United Kingdom had a referendum to decide wheter they want to remain or leave the European Union (EU). As a French citizen and a ardent member of the EU, I was interested by the outcome of the vote. Also, I have close family who reside and work in England, and the result will affect their lives.
For this analysis, the necessary libaries are loaded.
The results of the vote have been downloaded from The Electoral Commission's website. The commission is an independent elections watchdog and regulator of party and election finance that has been set up by the UK Parliament. The file contains the EU referendum results for all 326 English disctricts, the 22 principal areas of Wales, the 32 unitary authorities of Scotland, Northern Ireland and Gibraltar. In sum, there are 382 local areas declared.
<script type="text/javascript">
// jsData
function gvisDataPieChartID3ec63d7c93da () {
var data = new google.visualization.DataTable();
var datajson =
[
[
"Remain",
16141241,
0.4810815802
],
[
"Leave",
17410742,
0.5189184198
]
];
data.addColumn('string','choice');
data.addColumn('number','vote');
data.addColumn('number','pct');
data.addRows(datajson);
return(data);
}
// jsDrawChart
function drawChartPieChartID3ec63d7c93da() {
var data = gvisDataPieChartID3ec63d7c93da();
var options = {};
options["allowHtml"] = true;
options["width"] = 500;
options["height"] = 500;
options["title"] = "EU Referendum Result";
options["legend"] = "none";
options["pieSliceText"] = "label";
var chart = new google.visualization.PieChart(
document.getElementById('PieChartID3ec63d7c93da')
);
chart.draw(data,options);
}
// jsDisplayChart
(function() {
var pkgs = window.__gvisPackages = window.__gvisPackages || [];
var callbacks = window.__gvisCallbacks = window.__gvisCallbacks || [];
var chartid = "corechart";
// Manually see if chartid is in pkgs (not all browsers support Array.indexOf)
var i, newPackage = true;
for (i = 0; newPackage && i < pkgs.length; i++) {
if (pkgs[i] === chartid)
newPackage = false;
}
if (newPackage)
pkgs.push(chartid);
// Add the drawChart function to the global list of callbacks
callbacks.push(drawChartPieChartID3ec63d7c93da);
})();
function displayChartPieChartID3ec63d7c93da() {
var pkgs = window.__gvisPackages = window.__gvisPackages || [];
var callbacks = window.__gvisCallbacks = window.__gvisCallbacks || [];
window.clearTimeout(window.__gvisLoad);
// The timeout is set to 100 because otherwise the container div we are
// targeting might not be part of the document yet
window.__gvisLoad = setTimeout(function() {
var pkgCount = pkgs.length;
google.load("visualization", "1", { packages:pkgs, callback: function() {
if (pkgCount != pkgs.length) {
// Race condition where another setTimeout call snuck in after us; if
// that call added a package, we must not shift its callback
return;
}
while (callbacks.length > 0)
callbacks.shift()();
} });
}, 100);
}
// jsFooter
</script>
<script type="text/javascript" src="https://www.google.com/jsapi?callback=displayChartPieChartID3ec63d7c93da"></script>
* Number of local areas declared: 382
* Total (Eligible) Electorate: 46,500,001
* Turnout: 72.2%
* Rejected Ballots: 25,359
<script type="text/javascript">
// jsData
function gvisDataColumnChartID3ec65c190f4c () {
var data = new google.visualization.DataTable();
var datajson =
[
[
"England",
46.62382208,
53.37617792
],
[
"Scotland",
61.9960045,
38.0039955
],
[
"Wales",
47.47298421,
52.52701579
],
[
"Northern Ireland",
55.77517658,
44.22482342
]
];
data.addColumn('string','Country');
data.addColumn('number','Remain');
data.addColumn('number','Leave');
data.addRows(datajson);
return(data);
}
// jsDrawChart
function drawChartColumnChartID3ec65c190f4c() {
var data = gvisDataColumnChartID3ec65c190f4c();
var options = {};
options["allowHtml"] = true;
options["legend"] = "none";
options["axisTitlesPosition"] = "in";
options["vAxes"] = [{title:'%'}];
var chart = new google.visualization.ColumnChart(
document.getElementById('ColumnChartID3ec65c190f4c')
);
chart.draw(data,options);
}
// jsDisplayChart
(function() {
var pkgs = window.__gvisPackages = window.__gvisPackages || [];
var callbacks = window.__gvisCallbacks = window.__gvisCallbacks || [];
var chartid = "corechart";
// Manually see if chartid is in pkgs (not all browsers support Array.indexOf)
var i, newPackage = true;
for (i = 0; newPackage && i < pkgs.length; i++) {
if (pkgs[i] === chartid)
newPackage = false;
}
if (newPackage)
pkgs.push(chartid);
// Add the drawChart function to the global list of callbacks
callbacks.push(drawChartColumnChartID3ec65c190f4c);
})();
function displayChartColumnChartID3ec65c190f4c() {
var pkgs = window.__gvisPackages = window.__gvisPackages || [];
var callbacks = window.__gvisCallbacks = window.__gvisCallbacks || [];
window.clearTimeout(window.__gvisLoad);
// The timeout is set to 100 because otherwise the container div we are
// targeting might not be part of the document yet
window.__gvisLoad = setTimeout(function() {
var pkgCount = pkgs.length;
google.load("visualization", "1", { packages:pkgs, callback: function() {
if (pkgCount != pkgs.length) {
// Race condition where another setTimeout call snuck in after us; if
// that call added a package, we must not shift its callback
return;
}
while (callbacks.length > 0)
callbacks.shift()();
} });
}, 100);
}
// jsFooter
</script>
<script type="text/javascript" src="https://www.google.com/jsapi?callback=displayChartColumnChartID3ec65c190f4c"></script>
<script type="text/javascript">
// jsData
function gvisDataGeoChartID3ec6713b75d0 () {
var data = new google.visualization.DataTable();
var datajson =
[
[
"England",
53.37617792
],
[
"Scotland",
38.0039955
],
[
"Wales",
52.52701579
],
[
"Northern Ireland",
44.22482342
]
];
data.addColumn('string','Country');
data.addColumn('number','Leave');
data.addRows(datajson);
return(data);
}
// jsDrawChart
function drawChartGeoChartID3ec6713b75d0() {
var data = gvisDataGeoChartID3ec6713b75d0();
var options = {};
options["width"] = 556;
options["height"] = 347;
options["region"] = "GB";
options["displayMode"] = "regions";
options["resolution"] = "provinces";
options["colorAxis"] = {colors:['blue','red']};
var chart = new google.visualization.GeoChart(
document.getElementById('GeoChartID3ec6713b75d0')
);
chart.draw(data,options);
}
// jsDisplayChart
(function() {
var pkgs = window.__gvisPackages = window.__gvisPackages || [];
var callbacks = window.__gvisCallbacks = window.__gvisCallbacks || [];
var chartid = "geochart";
// Manually see if chartid is in pkgs (not all browsers support Array.indexOf)
var i, newPackage = true;
for (i = 0; newPackage && i < pkgs.length; i++) {
if (pkgs[i] === chartid)
newPackage = false;
}
if (newPackage)
pkgs.push(chartid);
// Add the drawChart function to the global list of callbacks
callbacks.push(drawChartGeoChartID3ec6713b75d0);
})();
function displayChartGeoChartID3ec6713b75d0() {
var pkgs = window.__gvisPackages = window.__gvisPackages || [];
var callbacks = window.__gvisCallbacks = window.__gvisCallbacks || [];
window.clearTimeout(window.__gvisLoad);
// The timeout is set to 100 because otherwise the container div we are
// targeting might not be part of the document yet
window.__gvisLoad = setTimeout(function() {
var pkgCount = pkgs.length;
google.load("visualization", "1", { packages:pkgs, callback: function() {
if (pkgCount != pkgs.length) {
// Race condition where another setTimeout call snuck in after us; if
// that call added a package, we must not shift its callback
return;
}
while (callbacks.length > 0)
callbacks.shift()();
} });
}, 100);
}
// jsFooter
</script>
<script type="text/javascript" src="https://www.google.com/jsapi?callback=displayChartGeoChartID3ec6713b75d0"></script>
We can see that Northern Ireland and Scotland voted *remain* while England and Wales voted *Leave*.
There are a couple of issues associated with the file provided by the GADM. First, the name of some of the administrative areas in the file are either incomplete or misspelled. I fix these entries below.
uk.map@data$NAME_2[56] <-"City of London"uk.map@data$NAME_2[140] <-"Aberdeen City"uk.map@data$NAME_2[145] <-"Dundee City"uk.map@data$NAME_2[150] <-"City of Edinburgh"uk.map@data$NAME_2[154] <-"Glasgow City"uk.map@data$NAME_2[159] <-"North Ayrshire"uk.map@data$NAME_2[162] <-"Perth and Kinross"uk.map@data$NAME_2[171] <-"Isle of Anglesey"uk.map@data$NAME_2[188] <-"Rhondda Cynon Taf"
Then, 192 adminstrative areas are given for England by GADM. The term administrative area includes both districts and ceremonial counties, which are larger subdivisions of England than districts. I extract from Wikipedia a list of English districts along with a list of ceremonial counties to which they belong.
Employing the English ceremonial county/district information from Wikipedia, I can now cross-correlate the election data from the Electoral Commission to the 192 GADM administrative areas.