A collection of useful tools for UK politics, including base maps and
datasets. Initially inspired by Bhaskar Karambelkar’s
but with the ability to create a hexagonal map of UK parliamentary
constituencies and local authorities. The package also includes
functions for data retrieval of current MPs and their consituency
details (as it requires calls to two different APIs, this function is
not included in my
mnis packages), and local
government composition. There are inbuilt datasets from the 2015 and
2017 UK General Elections and 2011 Census, courtesy of the British
Election Study, estimates of EU referendum votes from Chris Hanretty,
and hex codes for different party colours.
The most up-to-date documentation will always be at http://docs.evanodell.com/parlitools/.
parlitools is available on CRAN. To install on CRAN run:
Or, if you use pacman:
To install the development version from GitHub, run:
Functions and Data
party_colour - A tibble with the ID, name and hex code for the
official colour of a variety of political parties, taken from Wikipedia.
Includes all political parties with MPs and a number without MPs.
bes_2015 - A tibble with the British Election Study 2015 Constituency
Results Version 2.2. For information on all the variables in this
dataset, see the bes-2015
bes_2017 - A tibble with Great Britain constituencies results from the
2017 general election. This data can be linked to 2011 census
census_11 - A tibble with constituency-level census data.
leave_votes_west - The percentage of votes cast for leave in the 2016
EU referendum. Some constituencies have actual results and others only
have estimates by Chris Hanretty; in cases where the actual cote count
is known, both the estimates and the actual results are reported.
(Sources: Hanretty, C. (2017). Areal interpolation and the UK’s
referendum on EU membership. Journal of Elections, Public Opinion and
Parties, 27(4), 466–483.
Data Retrieval Functions
current_mps - Uses functions from
mnis to create a
tibble with data on all current MPs, their party affiliation and their
mps_on_date - Uses functions from
mnis to create a
tibble with data on all MPs from a given date, their party affiliation
and their constituency.
west_hex_map - A hexagonal cartogram, stored as a simple feature and
data frame, of Westminster parliamentary constituencies.
can be used to create maps like this:
local_hex_map - Hexagonal cartogram, A hexagonal cartogram, stored as
a simple feature and data frame, of all Local Authorities in England,
Wales and Scotland.
There are a variety of potentially relevant data sources and datasets on UK politics, far too many for me to include them all in this package.
- Electoral results dating back to 2005.
- A large selection of open data, including panel surveys, linked data and aggregated Twitter data, covering elections and referenda.
Open Council Data has data on the names, parties, and wards of all UK councillors, updated more or less weekly.
parlitoolsuses this site to power the