The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
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.
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.
The latest stable version of the stortingscrape
package
can be installed from by running CRAN:
install.packages("stortingscrape")
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:
::install_github("martigso/stortingscrape")
devtoolslibrary(stortingscrape)
Request all interpellations for a parliamentary session:
library(stortingscrape)
|> # sessions data are built into the package
parl_sessions head() # but can also be retrieved with `get_parlsessions()`
<- get_session_questions(parl_sessions$id[4], q_type = "interpellasjoner")
qsesh
<- list()
int1213
for(i in qsesh$id) {
message("Getting ", i)
<- get_question(i, good_manners = 2)
int1213[[i]]
}
<- do.call(rbind, int1213)
int1213
head(int1213)
Get biographies of all MPs for a given parliamentary period (will take ~30min to run):
# parliamentary periods (4 years) are built into the package,
parl_periods # but can also be retrieved with `get_parlperiods()`
<- get_parlperiod_mps(parl_periods$id[1], substitute = TRUE)
mps
<- lapply(mps$mp_id, get_mp_bio, good_manners = 2)
mps_bios
# Expand by all periods the MP has been in parliament
<- lapply(mps_bios, function(x){
mps_periods
data.frame(x$root,
$parl_periods)
x
})
<- do.call(rbind, mps_periods)
mps_periods
# Expand by all positions held in parliament
<- lapply(mps_bios, function(x){
mps_positions
if(nrow(x$parl_positions) < 1) return()
data.frame(x$root,
$parl_positions)
x
})
<- do.call(rbind, mps_positions) mps_positions
The back-end data is described in detail in the API of Stortinget.
You can find a list of all functions here.
Please use the following citation when using the package in research:
Søyland M (2024). “stortingscrape: An R package for accessing data from the Norwegian parliament.” URL: https://martigso.github.io/stortingscrape/articles/stortingscrape.html.
This can, as with all R-packages, also be generated using the
citation
function:
citation("stortingscrape")
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.