MyNixOS website logo
Description

Access Data from the Norwegian Parliament API.

Functions for retrieving general and specific data from the Norwegian Parliament, through the Norwegian Parliament API at <https://data.stortinget.no>.

stortingscrape

CRANVersion GithubVersion Downloads TotalDownloads R-CMD-check

stortingscrape is an R package for retrieving data from the Norwegian parliament (Stortinget) through their easily accessible back-end API. The data requested using the package require little to no further structuring. The scope of the package ranges from general data on the parliament itself (rules, session info, committees, etc) to data on the parties, bibliographies of the MPs, questions, hearings, debates, votes, and more.

The main goal of stortingscrape is to allow researchers to access any data from the Norwegian parliament easily, but also still be able to structure the data according to ones need. Most importantly, the package is facilitated for weaving together different parts of the data.stortinget.no API.

Installation

Because I’m not in control of the API itself, the CRAN package might at times be outdated. Submitting to CRAN is quite time consuming and will not be done more than once or twice a year.

CRAN (stable version)

The latest stable version of the stortingscrape package can be installed from by running CRAN:

install.packages("stortingscrape")

Github (development version)

The development version of the package can be installed either by cloning this repository and building the package in R or by installing via the devtools::install_github() function:

devtools::install_github("martigso/stortingscrape")
library(stortingscrape)

Usage examples

Request all interpellations for a parliamentary session:

library(stortingscrape)

parl_sessions |> # sessions data are built into the package
  head()         # but can also be retrieved with `get_parlsessions()`


qsesh <- get_session_questions(parl_sessions$id[4], q_type = "interpellasjoner")

int1213 <- list()

for(i in qsesh$id) {
  
  message("Getting ", i)
  
  int1213[[i]] <- get_question(i, good_manners = 2)

}

int1213 <- do.call(rbind, int1213)

head(int1213)

Get biographies of all MPs for a given parliamentary period (will take ~30min to run):

parl_periods # parliamentary periods (4 years) are built into the package,
             # but can also be retrieved with `get_parlperiods()`

mps <- get_parlperiod_mps(parl_periods$id[1], substitute = TRUE)

mps_bios <- lapply(mps$mp_id, get_mp_bio, good_manners = 2)

# Expand by all periods the MP has been in parliament
mps_periods <- lapply(mps_bios, function(x){
  
  data.frame(x$root,
             x$parl_periods)

})

mps_periods <- do.call(rbind, mps_periods)

# Expand by all positions held in parliament
mps_positions <- lapply(mps_bios, function(x){
  
  if(nrow(x$parl_positions) < 1) return()
  
  data.frame(x$root,
             x$parl_positions)
  
})

mps_positions <- do.call(rbind, mps_positions)

Data description

The back-end data is described in detail in the API of Stortinget.

Functions

You can find a list of all functions here.

Metadata

Version

0.3.0

License

Unknown

Platforms (77)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows