mnis
is an R package to pull data from the UK parliament through the Members’ Name Information Service API. It emphasises simplicity and ease of use, so that users unfamiliar with APIs can easily retrieve large volumes of high quality data.
All functions return data in JSON format, which is parsed to a list or data frame, depending on the data that is returned.
Functions are divided into three main types:
Reference Functions
Additional Information Functions
Fixed Scope Functions
There is also the mnis_base
function that allows for increased flexibility in all API requests.
install.packages(“mnis”)
install.packages(“devtools”) devtools::install_github(“EvanOdell/mnis”)
library(mnis)
The mnis_Base()
function accepts requests to the mnis API. The full list of request options is available on the mnis website: http://data.parliament.uk/membersdataplatform/memberquery.aspx
A series of functions to return reference data. This data is useful for providing parameters for other function calls. These functions do not accept any arguments.
ref_address_types()
ref_answering_bodies()
ref_areas()
ref_area_types()
ref_biography_categories()
ref_cabinets()
ref_committees()
ref_committee_types()
ref_constituencies()
ref_constituency_areas()
ref_constituency_types()
ref_countries()
ref_departments()
ref_disqualification_types()
ref_elections()
ref_election_types()
ref_end_reasons()
ref_experience_types()
ref_government_post_departments()
ref_government_posts()
ref_government_ranks()
ref_honourary_prefixes()
ref_honour_lists()
ref_honours()
ref_interest_categories()
ref_lords_membership_types()
ref_lords_ranks()
ref_opposition_post_departments()
ref_opposition_posts()
ref_opposition_ranks()
ref_other_parliaments()
ref_parliamentary_posts()
ref_parliamentary_ranks()
ref_parliament_types()
ref_parties()
ref_party_sub_types()
ref_photo_outputs()
ref_statuses()
ref_titles()
library(mnis)
x <- ref_titles()
x
# Title_Id Name
#1 22 Canon
#2 1 Dame
#4 3 Hon
#3 2 Dr
#6 5 Lord
#5 4 Lady
#7 6 Lt Col
#8 21 Lt Gen
#9 7 Miss
#10 8 Mr
#11 9 Mrs
#12 10 Ms
#13 11 Prof
#14 19 Professor
#15 12 Rev
#16 13 Rev Dr
#17 18 Revd
#18 20 Revd Dr
#20 15 Sir
#19 14 Reverend
#21 16 The Rev
#22 17 The Reverend
mnis_additional()
mnis_addresses()
mnis_basic_details()
mnis_biography_entries()
mnis_committees()
mnis_constituencies()
mnis_elections_contested
mnis_experiences()
mnis_government_posts()
mnis_honours()
mnis_house_memberships()
mnis_interests()
mnis_known_as()
mnis_maiden_speeches()
mnis_opposition_posts()
mnis_other_parliaments()
mnis_parliamentary_posts()
mnis_parties()
mnis_preferred_names()
mnis_staff()
mnis_statuses()
The mnis_extra()
function acts as a wrapper to the additional information functions. By default it calls all functions, which is equivalent to mnis_FullBiog()
.
There are seven fixed scope functions that return ready-made datasets. They are:
mnis_party_state()
mnis_constituency_results()
mnis_department()
mnis_general_election_results()
mnis_lords_type()
mnis_member_date()
mnis_party_state()
library(mnis)
x <- mnis_party_state()
x
# House Id Name MaleCount FemaleCount TotalCount
# Commons 4 Conservative 260 69 329
# Commons 15 Labour 130 101 231
# Commons 29 Scottish National Party 36 18 54
# Commons 17 Liberal Democrat 8 1 9
# Commons 7 Democratic Unionist Party 8 0 8
# Commons 8 Independent 1 3 4
# Commons 30 Sinn Fein 4 0 4
# Commons 22 Plaid Cymru 2 1 3
# Commons 31 Social Democratic & Labour Party 2 1 3
# Commons 38 Ulster Unionist Party 2 0 2
# Commons 44 Green Party 0 1 1
# Commons 47 Speaker 1 0 1
# Commons 35 UK Independence Party 1 0 1