Provides various tools for analysing UK political data, including creating political cartograms and retrieving data.
A collection of useful tools for UK politics, including base maps and datasets. Initially inspired by Bhaskar Karambelkar's
tilegrams package, but with the ability to create a hexagonal map of UK parliamentary constituencies. 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 data from the 2015 UK General Election, courtesy of the British Election Study.
The most up-to-date documentation for the development version 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:
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. (Sources: https://en.wikipedia.org/wiki/Wikipedia:Index_of_United_Kingdom_political_parties_meta_attributes,
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 vignette (Source: http://www.britishelectionstudy.com/data-object/2015-bes-constituency-results-with-census-and-candidate-data/)
bes_2017 - A tibble with Great Britain constituencies results from the 2017 general election. This data can be linked to 2011 census information in
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: https://secondreading.uk/brexit/brexit-votes-by-constituency/ http://www.bbc.co.uk/news/uk-northern-ireland-36616830)
current_mps - Uses functions from
mnis to create a tibble with data on all current MPs, their party affiliation and their constituency.
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.
west_hex_map 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 Commission - Electoral results dating back to 2005.
British Election Study - 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.
parlitools no longer stores local council party data. The most up-to-date
data on the political make-up of local councils and individual councillors
can be be accessed with the new
leave_votes_west dataset to include the latest best-estimates
of constituency level votes from Chris Hanretty and the actual votes, where
Fixed errors caused by duplicated vignette names.
Eliminated some dependencies.
party_id in the
party_colour dataset to a character vector.
Otherwise very minor update, some tweaks to docs layout.
council_datadataset to be accurate as of 2017-11-24.
council_data dataset to be accurate as of 2017-09-13.
combined_leave_vote column to
leave_votes_west dataset with the
actual leave vote if known and the Chris Hanretty estimate if not known.
Vote percentages in
leave_votes_west are now all numeric class.
Improvements to documentation to improve clarity and readability.
Better example plots in introductory vignette.
The tidying functions are now all internal to the package and not exported.
bes_2017 dataset, with results of 2017 General Election, taken from
the 2017 British Election Study. This dataset replaces the
It also replicates some of the data in the
Census data from the British Election Study has been moved to its own
separate file, named
Changes to vignettes to comply with CRAN policies and to reduce the time needed to check the package.
Reduction in the number of similar vignette examples to reduce build time.
council_data dataset to be accurate as of 2017-07-14.
ge_2017 dataset, with results of 2017 General Election, linked with
constituency data from
mps_on_date()that were causing problems on Windows.
leave_votes_westcontaining estimates and - where available - official counts of the proportion of leave votes in the 2016 EU referendum.
bes_2015 to use V2.21 from the British Election Study.
council_data dataset, with details on the parties controlling local
councils across the UK.
Fixed bug in
mps_on_date where function did not return constituency data.
mps_on_date also now accepts dates in any format or class that can be
as.Date() to a date format.
Fixed names party names in
party_colour to align with names used in
Fixed spelling mistakes in Endiburgh constituency names in
mps_on_date(), allowing users to decide which style snake_case, camelCase and period.case they want variable names to be in, if
parlitoolsto create scaled maps with the
local_hex_map, a hexagonal map of all local authority areas in Scotland, Wales and England.
mps_on_datefunction downloads information on every MP and their constituency who was a member of the house on a single given date, or between two given dates.
parlitools, a package for retrieving and analysing UK political data. The package includes datasets from the British Election Study, a hexagonal map of all UK constituencies, and party colour hex codes.
The package includes a dataset with 2015 General Election results and census information for each constituency in Scotland, Wales and England, taken from the British Election Study.
The package also includes a dataset (
party_colours) with the hex code for
the official colours of UK political parties.
west_hex_map) of all 650 constituencies in the UK.
current_mpsfunction downloads information on every sitting MP and their constituency.