Parliament of Finland: unofficial API client

This R package provides tools to access Parliament of Finland data from the unofficial Kansan Muisti 2.0 API. For API documentation, check here.

Installation and usage

Installing the package (Installing the package)
Gender analysis (Estimating genders)

Available data sources and tools

The following API endpoints are currently wrapped by finpar:

| Data | API endpoint | Function | |---------------------|------------------------------------|------------------------------------| | Parliamentary terms | http://kansanmuisti.fi/api/v1/term | term() | | Members of the Parliament | http://kansanmuisti.fi/api/v1/member | member() | | Plenary sessions | http://kansanmuisti.fi/api/v1/plenary_session | plenary_session() |

Installation

Install the development version:

library(devtools)
install_github("ropengov/finpar")

Load the library:

library(finpar)

Set UTF-8 encoding:

Sys.setlocale(locale="UTF-8") 

Parliament terms

All terms of the Finnish parliament in 1907-2011

all_terms <- term()
# Show the first ones in a table:
library(knitr)
kable(head(all_terms))

Get a specific term defined by ID

term_2011 <- term(id=1)  
print(term_2011)

Parliament members

Get all parliament members and plot their age distribution

all_members <- member()
ages <- sapply(all_members, function (x) {x$age})
hist(ages, col = "gray", xlab = "Age", main = "Age distribution of parliament members", las = 1)

Get a specific member defined by ID:

jorn_donner <- member(id=30)  

# List available variables
print(names(jorn_donner))

# Check age
jorn_donner$age

Plenary sessions

Get all plenary sessions

all_plenary_sessions <- plenary_session()

Get a specific plenary session defined by ID

session <- plenary_session(id=30)  

# List available variables
kable(session)

Genders

Use genderizeR to estimate gender for first names (note that there might be some inaccuracies in gender estimation for Finnish names):

# devtools::install_github("kalimu/genderizeR")
suppressPackageStartupMessages(library(genderizeR))
x <- c("Sauli", "Tarja", "Mauno")
givenNames <- findGivenNames(x, progress = FALSE)
g <- genderize(x, genderDB=givenNames, blacklist=NULL, progress = FALSE)
kable(g)

Related

R code to calculate co-sponsorship networks from bills (and motions) passed in the Finnish Parliament by François briatte

Acknowledgements

R client for the unofficial API of Parliament of Finland provided by NGO Kansan Muisti. Parliament of Finland does not provide an official API, but Kansan Muisti does provide a RESTful API to a database mostly compiled by scraping data from parliament's web page. Great work !

Licensing and Citations

This work can be freely used, modified and distributed under the MIT license.

citation("finpar")

Session info

This vignette was created with

sessionInfo()


rOpenGov/finpar documentation built on May 26, 2019, 7:48 p.m.