parlitools

A collection of useful tools for UK politics

https://github.com/evanodell/parlitools

Science Score: 36.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
    Found 2 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (18.0%) to scientific vocabulary

Keywords

constituency data-retrieval datasets political-parties politics r
Last synced: 6 months ago · JSON representation

Repository

A collection of useful tools for UK politics

Basic Info
Statistics
  • Stars: 25
  • Watchers: 2
  • Forks: 0
  • Open Issues: 7
  • Releases: 18
Topics
constituency data-retrieval datasets political-parties politics r
Created almost 9 years ago · Last pushed almost 3 years ago
Metadata Files
Readme Changelog License

README.Rmd

---
output: github_document
---


```{r, echo = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "README-"
)
```

[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/parlitools)](https://cran.r-project.org/package=parlitools)
[![GitHub tag](https://img.shields.io/github/tag/evanodell/parlitools.svg)](https://github.com/evanodell/parlitools)
[![](https://cranlogs.r-pkg.org/badges/grand-total/parlitools)](https://dgrtwo.shinyapps.io/cranview/)
 [![R build status](https://github.com/EvanOdell/parlitools/workflows/R-CMD-check/badge.svg)](https://github.com/EvanOdell/parlitools/actions)
[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/evanodell/parlitools?branch=master&svg=true)](https://ci.appveyor.com/project/evanodell/parlitools)
[![Coverage Status](https://img.shields.io/codecov/c/github/evanodell/parlitools/master.svg)](https://codecov.io/github/evanodell/parlitools?branch=master)
[![DOI](https://zenodo.org/badge/86801920.svg)](https://zenodo.org/badge/latestdoi/86801920)

# parlitools

A collection of useful tools for UK politics, including base maps and datasets. Initially inspired by Bhaskar Karambelkar's [`tilegrams`](https://cran.r-project.org/package=tilegramsR) package, 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 [`hansard`](https://cran.r-project.org/package=hansard) or [`mnis`](https://cran.r-project.org/package=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/.

## Installing

`parlitools` is available on CRAN. To install on CRAN run:

```
install.packages("parlitools")
```

Or, if you use [pacman](https://cran.r-project.org/package=pacman):

```
pacman::p_load(parlitools)
```

To install the development version from GitHub, run:

```
##install.packages("parlitools")
devtools::install_github("evanodell/parlitools")
```

## Functions and Data

For more details see [the full documentation](https://docs.evanodell.com/parlitools/reference) or the [vignettes](https://docs.evanodell.com/parlitools/articles/).

### Included 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. (Sources: https://en.wikipedia.org/wiki/Wikipedia:Index_of_United_Kingdom_political_parties_meta_attributes, [`mnis::ref_parties()`](https://cran.r-project.org/package=mnis))

`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](http://docs.evanodell.com/parlitools/articles/bes-2015.html) (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`](https://docs.evanodell.com/parlitools/reference/bes.html).

`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. https://doi.org/10.1080/17457289.2017.1287081,  http://www.bbc.co.uk/news/uk-northern-ireland-36616830)

### Data Retrieval Functions

`current_mps` - Uses functions from `hansard` and `mnis` to create a tibble with data on all current MPs, their party affiliation and their constituency.

`mps_on_date` - Uses functions from `hansard` and `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:

```{r, out.width= '456px', echo=FALSE}
knitr::include_graphics("tools/hex_map.png")
```

`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.

### Using `parlitools`

For more details, please see the [introductory vignette](https://docs.evanodell.com/parlitools/articles/introduction.html), [using `parlitools` with `cartogram`](https://docs.evanodell.com/parlitools/articles/using-cartograms.html), [mapping local authorities](https://docs.evanodell.com/parlitools/articles/mapping-local-authorities.html) and the vignette detailing [British Election Study 2015](https://docs.evanodell.com/parlitools/articles/bes-2015.html) variables.

## Data Sources

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](http://www.electoralcommission.org.uk/our-work/our-research/electoral-data) - Electoral results dating back to 2005.

* [British Election Study](http://www.britishelectionstudy.com/data/) - A large selection of open data, including panel surveys, linked data and aggregated Twitter data, covering elections and referenda.

* My [`hansard`](https://cran.r-project.org/package=hansard) & [`mnis`](https://cran.r-project.org/package=mnis) data retrieval packages for parliamentary APIs.

* [Open Council Data](http://opencouncildata.co.uk/) has data on the names, parties, and wards of all UK councillors, updated more or less weekly. `parlitools` uses this site to power the `council_seats()` function.

Owner

  • Name: Evan Odell
  • Login: evanodell
  • Kind: user
  • Location: Berlin

Data analysis | Statistics | R packages

GitHub Events

Total
  • Watch event: 2
Last Year
  • Watch event: 2

Packages

  • Total packages: 1
  • Total downloads:
    • cran 450 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 12
  • Total maintainers: 1
cran.r-project.org: parlitools

Tools for Analysing UK Politics

  • Versions: 12
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 450 Last month
Rankings
Stargazers count: 11.3%
Average: 28.2%
Forks count: 28.8%
Dependent packages count: 29.8%
Downloads: 35.4%
Dependent repos count: 35.5%
Maintainers (1)
Last synced: 7 months ago

Dependencies

.github/workflows/R-CMD-check.yaml actions
  • actions/cache v2 composite
  • actions/checkout v2 composite
  • actions/upload-artifact main composite
  • r-lib/actions/setup-pandoc v1 composite
  • r-lib/actions/setup-r v1 composite
DESCRIPTION cran
  • R >= 3.3.0 depends
  • dplyr * imports
  • hansard * imports
  • magrittr * imports
  • mnis * imports
  • readr * imports
  • sf * imports
  • snakecase * imports
  • stringi * imports
  • cartogram * suggests
  • covr * suggests
  • devtools * suggests
  • ggplot2 * suggests
  • htmltools * suggests
  • htmlwidgets * suggests
  • janitor * suggests
  • knitr * suggests
  • leaflet * suggests
  • rgdal * suggests
  • rmarkdown * suggests
  • testthat * suggests
  • tibble * suggests
docs/articles/introduction_files/leaflet-binding-2.0.0/lib/leaflet-omnivore/package.json npm
  • browserify 13.0.1 development
  • jshint 2.9.2 development
  • mapbox.js 2.4.0 development
  • mocha ~2.5.3 development
  • phantomjs-prebuilt 2.1.7 development
  • st 1.1.0 development
  • tape 4.5.1 development
  • uglify-js ^2.6.2 development
  • zuul ~3.10.1 development
  • brfs 1.4.3
  • corslite 0.0.7
  • csv2geojson ~5.0.0
  • polyline 0.2.0
  • togeojson 0.13.0
  • topojson 1.6.26
  • wellknown 0.4.2
docs/articles/introduction_files/leaflet-binding-2.0.0/lib/leaflet-providers/package.json npm
  • chai ^4.1.2 development
  • eslint ^3.16.1 development
  • eslint-plugin-html ^2.0.1 development
  • mocha ^3.2.0 development
  • mocha-phantomjs-core ^2.1.1 development
  • mversion ^1.10.1 development
  • phantomjs-prebuilt ^2.1.16 development
  • uglify-js ^2.4.15 development
docs/articles/introduction_files/leaflet-binding-2.0.0/plugins/Leaflet.markercluster/package.json npm
  • jake ~0.5.16 development
  • jshint ~2.1.3 development
  • karma ~0.8.5 development
  • leaflet ~1.0.3 development
  • magic-string ^0.7.0 development
  • mocha ~1.10.0 development
  • uglify-js ~2.6.0 development
docs/articles/introduction_files/leaflet-binding-2.0.1/lib/leaflet-omnivore/package.json npm
  • browserify 13.0.1 development
  • jshint 2.9.2 development
  • mapbox.js 2.4.0 development
  • mocha ~2.5.3 development
  • phantomjs-prebuilt 2.1.7 development
  • st 1.1.0 development
  • tape 4.5.1 development
  • uglify-js ^2.6.2 development
  • zuul ~3.10.1 development
  • brfs 1.4.3
  • corslite 0.0.7
  • csv2geojson ~5.0.0
  • polyline 0.2.0
  • togeojson 0.13.0
  • topojson 1.6.26
  • wellknown 0.4.2
docs/articles/introduction_files/leaflet-binding-2.0.1/lib/leaflet-providers/package.json npm
  • chai ^4.1.2 development
  • eslint ^3.16.1 development
  • eslint-plugin-html ^2.0.1 development
  • mocha ^3.2.0 development
  • mocha-phantomjs-core ^2.1.1 development
  • mversion ^1.10.1 development
  • phantomjs-prebuilt ^2.1.16 development
  • uglify-js ^2.4.15 development
docs/articles/introduction_files/leaflet-binding-2.0.1/plugins/Leaflet.markercluster/package.json npm
  • jake ~0.5.16 development
  • jshint ~2.1.3 development
  • karma ~0.8.5 development
  • leaflet ~1.0.3 development
  • magic-string ^0.7.0 development
  • mocha ~1.10.0 development
  • uglify-js ~2.6.0 development
docs/articles/mapping-local-authorities_files/leaflet-binding-2.0.0/lib/leaflet-omnivore/package.json npm
  • browserify 13.0.1 development
  • jshint 2.9.2 development
  • mapbox.js 2.4.0 development
  • mocha ~2.5.3 development
  • phantomjs-prebuilt 2.1.7 development
  • st 1.1.0 development
  • tape 4.5.1 development
  • uglify-js ^2.6.2 development
  • zuul ~3.10.1 development
  • brfs 1.4.3
  • corslite 0.0.7
  • csv2geojson ~5.0.0
  • polyline 0.2.0
  • togeojson 0.13.0
  • topojson 1.6.26
  • wellknown 0.4.2
docs/articles/mapping-local-authorities_files/leaflet-binding-2.0.0/lib/leaflet-providers/package.json npm
  • chai ^4.1.2 development
  • eslint ^3.16.1 development
  • eslint-plugin-html ^2.0.1 development
  • mocha ^3.2.0 development
  • mocha-phantomjs-core ^2.1.1 development
  • mversion ^1.10.1 development
  • phantomjs-prebuilt ^2.1.16 development
  • uglify-js ^2.4.15 development
docs/articles/mapping-local-authorities_files/leaflet-binding-2.0.0/plugins/Leaflet.markercluster/package.json npm
  • jake ~0.5.16 development
  • jshint ~2.1.3 development
  • karma ~0.8.5 development
  • leaflet ~1.0.3 development
  • magic-string ^0.7.0 development
  • mocha ~1.10.0 development
  • uglify-js ~2.6.0 development
docs/articles/mapping-local-authorities_files/leaflet-binding-2.0.1/lib/leaflet-omnivore/package.json npm
  • browserify 13.0.1 development
  • jshint 2.9.2 development
  • mapbox.js 2.4.0 development
  • mocha ~2.5.3 development
  • phantomjs-prebuilt 2.1.7 development
  • st 1.1.0 development
  • tape 4.5.1 development
  • uglify-js ^2.6.2 development
  • zuul ~3.10.1 development
  • brfs 1.4.3
  • corslite 0.0.7
  • csv2geojson ~5.0.0
  • polyline 0.2.0
  • togeojson 0.13.0
  • topojson 1.6.26
  • wellknown 0.4.2
docs/articles/mapping-local-authorities_files/leaflet-binding-2.0.1/lib/leaflet-providers/package.json npm
  • chai ^4.1.2 development
  • eslint ^3.16.1 development
  • eslint-plugin-html ^2.0.1 development
  • mocha ^3.2.0 development
  • mocha-phantomjs-core ^2.1.1 development
  • mversion ^1.10.1 development
  • phantomjs-prebuilt ^2.1.16 development
  • uglify-js ^2.4.15 development
docs/articles/mapping-local-authorities_files/leaflet-binding-2.0.1/plugins/Leaflet.markercluster/package.json npm
  • jake ~0.5.16 development
  • jshint ~2.1.3 development
  • karma ~0.8.5 development
  • leaflet ~1.0.3 development
  • magic-string ^0.7.0 development
  • mocha ~1.10.0 development
  • uglify-js ~2.6.0 development
docs/articles/using-cartograms_files/leaflet-binding-2.0.0/lib/leaflet-omnivore/package.json npm
  • browserify 13.0.1 development
  • jshint 2.9.2 development
  • mapbox.js 2.4.0 development
  • mocha ~2.5.3 development
  • phantomjs-prebuilt 2.1.7 development
  • st 1.1.0 development
  • tape 4.5.1 development
  • uglify-js ^2.6.2 development
  • zuul ~3.10.1 development
  • brfs 1.4.3
  • corslite 0.0.7
  • csv2geojson ~5.0.0
  • polyline 0.2.0
  • togeojson 0.13.0
  • topojson 1.6.26
  • wellknown 0.4.2
docs/articles/using-cartograms_files/leaflet-binding-2.0.0/lib/leaflet-providers/package.json npm
  • chai ^4.1.2 development
  • eslint ^3.16.1 development
  • eslint-plugin-html ^2.0.1 development
  • mocha ^3.2.0 development
  • mocha-phantomjs-core ^2.1.1 development
  • mversion ^1.10.1 development
  • phantomjs-prebuilt ^2.1.16 development
  • uglify-js ^2.4.15 development
docs/articles/using-cartograms_files/leaflet-binding-2.0.0/plugins/Leaflet.markercluster/package.json npm
  • jake ~0.5.16 development
  • jshint ~2.1.3 development
  • karma ~0.8.5 development
  • leaflet ~1.0.3 development
  • magic-string ^0.7.0 development
  • mocha ~1.10.0 development
  • uglify-js ~2.6.0 development
docs/articles/using-cartograms_files/leaflet-binding-2.0.1/lib/leaflet-omnivore/package.json npm
  • browserify 13.0.1 development
  • jshint 2.9.2 development
  • mapbox.js 2.4.0 development
  • mocha ~2.5.3 development
  • phantomjs-prebuilt 2.1.7 development
  • st 1.1.0 development
  • tape 4.5.1 development
  • uglify-js ^2.6.2 development
  • zuul ~3.10.1 development
  • brfs 1.4.3
  • corslite 0.0.7
  • csv2geojson ~5.0.0
  • polyline 0.2.0
  • togeojson 0.13.0
  • topojson 1.6.26
  • wellknown 0.4.2
docs/articles/using-cartograms_files/leaflet-binding-2.0.1/lib/leaflet-providers/package.json npm
  • chai ^4.1.2 development
  • eslint ^3.16.1 development
  • eslint-plugin-html ^2.0.1 development
  • mocha ^3.2.0 development
  • mocha-phantomjs-core ^2.1.1 development
  • mversion ^1.10.1 development
  • phantomjs-prebuilt ^2.1.16 development
  • uglify-js ^2.4.15 development
docs/articles/using-cartograms_files/leaflet-binding-2.0.1/plugins/Leaflet.markercluster/package.json npm
  • jake ~0.5.16 development
  • jshint ~2.1.3 development
  • karma ~0.8.5 development
  • leaflet ~1.0.3 development
  • magic-string ^0.7.0 development
  • mocha ~1.10.0 development
  • uglify-js ~2.6.0 development
docs/index_files/leaflet-binding-2.0.0/lib/leaflet-omnivore/package.json npm
  • browserify 13.0.1 development
  • jshint 2.9.2 development
  • mapbox.js 2.4.0 development
  • mocha ~2.5.3 development
  • phantomjs-prebuilt 2.1.7 development
  • st 1.1.0 development
  • tape 4.5.1 development
  • uglify-js ^2.6.2 development
  • zuul ~3.10.1 development
  • brfs 1.4.3
  • corslite 0.0.7
  • csv2geojson ~5.0.0
  • polyline 0.2.0
  • togeojson 0.13.0
  • topojson 1.6.26
  • wellknown 0.4.2
docs/index_files/leaflet-binding-2.0.0/lib/leaflet-providers/package.json npm
  • chai ^4.1.2 development
  • eslint ^3.16.1 development
  • eslint-plugin-html ^2.0.1 development
  • mocha ^3.2.0 development
  • mocha-phantomjs-core ^2.1.1 development
  • mversion ^2.0.0 development
  • phantomjs-prebuilt ^2.1.16 development
  • uglify-js ^2.4.15 development
docs/index_files/leaflet-binding-2.0.0/plugins/Leaflet.markercluster/package.json npm
  • jake ~0.5.16 development
  • jshint ~2.1.3 development
  • karma ~0.8.5 development
  • leaflet ~1.0.3 development
  • magic-string ^0.7.0 development
  • mocha ~1.10.0 development
  • uglify-js ~2.6.0 development
docs/index_files/leaflet-binding-2.0.1/lib/leaflet-omnivore/package.json npm
  • browserify 13.0.1 development
  • jshint 2.9.2 development
  • mapbox.js 2.4.0 development
  • mocha ~2.5.3 development
  • phantomjs-prebuilt 2.1.7 development
  • st 1.1.0 development
  • tape 4.5.1 development
  • uglify-js ^2.6.2 development
  • zuul ~3.10.1 development
  • brfs 1.4.3
  • corslite 0.0.7
  • csv2geojson ~5.0.0
  • polyline 0.2.0
  • togeojson 0.13.0
  • topojson 1.6.26
  • wellknown 0.4.2
docs/index_files/leaflet-binding-2.0.1/lib/leaflet-providers/package.json npm
  • chai ^4.1.2 development
  • eslint ^3.16.1 development
  • eslint-plugin-html ^2.0.1 development
  • mocha ^3.2.0 development
  • mocha-phantomjs-core ^2.1.1 development
  • mversion ^1.10.1 development
  • phantomjs-prebuilt ^2.1.16 development
  • uglify-js ^2.4.15 development
docs/index_files/leaflet-binding-2.0.1/plugins/Leaflet.markercluster/package.json npm
  • jake ~0.5.16 development
  • jshint ~2.1.3 development
  • karma ~0.8.5 development
  • leaflet ~1.0.3 development
  • magic-string ^0.7.0 development
  • mocha ~1.10.0 development
  • uglify-js ~2.6.0 development