Type: | Package |
Title: | Access Data from the Norwegian Parliament API |
Version: | 0.4.1 |
Description: | Functions for retrieving general and specific data from the Norwegian Parliament, through the Norwegian Parliament API at https://data.stortinget.no. |
URL: | https://github.com/martigso/stortingscrape, https://martigso.github.io/stortingscrape/ |
BugReports: | https://github.com/martigso/stortingscrape/issues |
Depends: | R (≥ 4.2.0) |
Encoding: | UTF-8 |
Imports: | rvest, httr2, parallel, stringr |
Suggests: | magick, rmarkdown, knitr, pscl |
License: | GPL (≥ 3) |
VignetteBuilder: | knitr |
RoxygenNote: | 7.3.2 |
LazyData: | true |
NeedsCompilation: | no |
Packaged: | 2025-04-07 07:41:01 UTC; martigso |
Author: | Martin Søyland |
Maintainer: | Martin Søyland <martin.soyland@stv.uio.no> |
Repository: | CRAN |
Date/Publication: | 2025-04-07 08:00:02 UTC |
Storting cases in the 2019-2020 session
Description
A dataset containing all cases of the 2019-2020 parliamentary session in Stortinget
Usage
cases
Format
A list with four elements
- $root
main data on the MP
- $topics
named list by case id
- $proposers
named list by case id
- $spokespersons
named list by case id
- Further description:
Source
https://data.stortinget.no/eksport/saker?sesjonid=2019-2020
Vote id 85196
Description
A dataset containing all vote information on case id 85196
Usage
covid_relief
Format
A data frame with 22 columns and 71 rows
- response_date
Date of data retrieval
- version
Data version from the API
- case_id
Case id up for vote
- alternative_vote
Whether vote is an alternative vote
- n_for
Number of votes for
- n_absent
Number of MPs absent
- n_against
Number of votes against
- treatment_order
Order of treated votes
- agenda_case_number
Case number on the agenda of the meeting
- free_vote
Logical indication of whether the vote is related to the case as a whole
- comment
Vote comment
- meeting_map_number
Number on the meeting map
- personal_vote
Logical indication of whether vote was recorded as roll call or not
- president_id
Id of president holding president chair at the time of voting
- president_party_id
Party of the sitting president
- adopted
Logical indication of whether the proposal voted on was adopted
- vote_id
Id of vote
- vote_method
Voting method
- vote_result_type
Result type (enstemmig_vedtatt = unanimously adopted)
- vote_result_type_text
See vote_result_type
- vote_topic
Description of the proposal voted upon
- vote_datetime
Date and time of vote
Source
https://data.stortinget.no/eksport/voteringer?sakid=85196
Vote id 85196 results
Description
A dataset containing vote matrix on vote id 17689
Usage
covid_relief_result
Format
A data frame with 8 columns and 169 rows
- response_date
Date of data retrieval
- version
Data version from the API
- vote_id
Id of vote
- mp_id
MP id
- party_id
Party id
- vote
Vote: for, mot (against), ikke_tilstede (absent)
- permanent_sub_for
Id of the MP originally holding the seat, if the substitute is
- sub_for
Id of the MP originally holding the seat
Source
https://data.stortinget.no/eksport/voteringsresultat?voteringid=17689
Parliamentary committees over all sessions
Description
Imports data on all committee names and ids over all sessions in the data.stortinget.no API.
Usage
get_all_committees()
Value
A data frame of committees, with the variables:
response_date | Date of data retrieval |
version | Data version from the API |
id | Id of the committee |
name | Name of the committee |
sessionid | Id of session (empty) |
See Also
Examples
## Not run:
coms <- get_all_committees()
head(coms)
## End(Not run)
All parliamentary parties
Description
A function for retrieving all Norwegian parliamentary parties in the data.stortinget.no API.
Usage
get_all_parties()
Value
A data.frame of all parties, with the variables:
response_date | Date of data retrieval |
version | Data version from the API |
id | Id of the party |
name | Name of the party |
represented_party | Whether the party is represented at the time of download |
sessionid | Id of session (empty) |
period_id | Id of parliamentary period (empty) |
See Also
Examples
## Not run:
parties <- get_all_parties()
head(parties)
## End(Not run)
Retreive a parliamentary case
Description
A function for retrieving single parliamentary case by id.
Usage
get_case(caseid = NA, good_manners = 0)
Arguments
caseid |
Character string indicating the id of the case to request |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
Value
A list with seven data frame elements:
-
$root (main data on the case)
response_date Date of data retrieval version Data version from the API document_group Case document group type finalized Whether the case finalized reference Relevant publication references id Case id req_text Recommendation (proposal) text committee_id Id of committee handling the case title_short Case short title decision_short Case decision_short parenthesis_text Case parenthesis text case_number Case number session_id Session id proceedings_id Type of proceeding id proceedings_name Type of proceeding name status Status for case title Case title (long) type Case type decision_text Decision text -
$topic (the topics related to the case)
is_main_topic Is this (row) the main topic? main_topic_id Id for main topic id Topic id navn Topic name -
$publication_references (references for publications on the case)
export_id Id for export of publication (used in ?get_publication) link_text Publication title link_url URL to publication type Publication type subtype Publication subtype (chamber) -
$proposers (MPs behind case proposal, when relevant)
mp_id MPs id party_id Party id of MPs sub_mp Whether MPs are substitutes -
$proceeding_steps (case proceeding steps)
step_name Name of steps step_number Step order for case outdated Whether the step type is outdated -
$spokespersons (all MPs that are spokespersons for the case)
mp_id MPs id party_id Party id of MPs sub_mp Whether MPs are substitutes -
$keywords (all keywords associated with the case)
keyword Keywords for the case
See Also
Examples
## Not run:
# Get one case
case <- get_case("30233")
case
# Get multiple cases
cases <- lapply(c("30233", "30362", "30234", "30236"), get_case, good_manners = 2)
cases_root <- lapply(cases, function(x) x$root)
cases_root <- do.call(rbind, cases_root)
cases_root
cases_keywords <- lapply(1:nrow(cases_root), function(x){
tmp <- cases[[x]]$keywords
tmp$case_id <- cases_root$id[x]
return(tmp)
})
cases_keywords <- do.call(rbind, cases_keywords)
cases_keywords
## End(Not run)
Get list of electoral districts
Description
A function for retrieving current and/or historical electoral districts (counties) for the Norwegian parliament.
Usage
get_counties(historical = FALSE)
Arguments
historical |
Logical. Whether or not to include historical counties. |
Value
A data frame with the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
historical_county | Whether the county is historical (no longer exists) |
id | Id of the county |
name | Name of the county |
Examples
## Not run:
# Request one MP by id
get_counties()
# With historical counties
get_counties(historical = TRUE)
## End(Not run)
Retreive vote decision for a specified vote
Description
A function for retrieving vote decisions from a specific vote. Vote data are only available from the 2011-2012 session
Usage
get_decision_votes(voteid = NA, good_manners = 0)
Arguments
voteid |
Character string indicating the id of the vote to request all votes from |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
Value
A data.frame with the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
vote_id | Id of the vote |
decision_code | General code for decision |
decision_comment | Comments for the decision |
decision_number | Decision number |
decision_reference | Reference for the decision |
decision_text | Full text of the decision |
See Also
get_session_decisions get_proposal_votes get_vote get_result_vote
Examples
## Not run:
decision <- get_decision_votes(123)
decision
## End(Not run)
Retrieve the hearing input for a specified hearing
Description
A function for retrieving the hearing input for a specified hearing.
Usage
get_hearing_input(hearingid = NA, good_manners = 0)
Arguments
hearingid |
Character string indicating the id of the hearing to retrieve. |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
Value
A data.frame the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
hearing_id | Id of the hearing |
hearing_type | Type of hearing |
committee_id | Id of committee responsible for the hearing |
hearing_input_date | Date of receiving input |
hearing_input_id | Hearing input id |
hearing_input_organization | Organization giving input |
hearing_input_text | Full text of the hearing input |
hearing_input_title | Title of the hearing input |
See Also
get_session_hearings get_hearing_program get_written_hearing_input
Examples
## Not run:
get_hearing_input(hearingid = 10004166)
## End(Not run)
Retrieve the hearing program for a specified hearing
Description
A function for retrieving the hearing program for a specified hearing. The earlier periods (around 2005 and back) are less rich with data on some variables
Usage
get_hearing_program(hearingid = NA, good_manners = 0)
Arguments
hearingid |
Character string indicating the id of the hearing to retrieve. |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
Value
A data.frame with the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
hearing_id | Id of the hearing |
hearing_type | Type of hearing |
committee_id | Id of committee responsible for the hearing |
hearing_program_date | Date hearing program |
hearing_program_footnote | Footnote for hearing program |
order_number | Order number for the hearing program element |
text | Description of the hearing participant |
time_indication | Time stamp for participant hearing input |
date | Date of participant input in hearing |
See Also
get_session_hearings get_hearing_input get_written_hearing_input
Examples
## Not run:
s0910 <- get_session_hearings("2009-2010")
hearing <- get_hearing_program(s0910$hearing$hearing_id[1])
head(hearing)
## End(Not run)
Retreive agenda for a specified meeting
Description
A function for retrieving the agenda for a specific meeting.
Usage
get_meeting_agenda(meetingid = NA, good_manners = 0)
Arguments
meetingid |
Character string indicating the id of the meeting to request all votes from |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
Value
A data.frame with the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
agenda_number | The agenda number for the session |
meeting_date | Date of the meeting |
meeting_id | Meeting id |
meeting_place | Where the meeting was held |
agenda_case_reference | Reference for the case on the agenda |
agenda_case_number | Case number |
agenda_case_text | Case description |
agenda_case_type | Case type |
footnote | Footnote for the case |
proposition_id | If relevant, belonging proposition id |
committee_id | If relevant, id of the responsible committee |
legacy_question_id | Legacy question id, only used for mathing with old data (pre 10.12.2024) |
loose_proposals | Whether there are loose proposals to the case |
case_id | Id of the case |
question_hour_type | If relevant, type of question hour |
question_id | If relevant, question id |
See Also
get_session_meetings get_case get_question get_question_hour
Examples
## Not run:
meetings0910 <- get_session_meetings("2009-2010")
meeting_agenda <- get_meeting_agenda(meetings0910$meeting_id[161])
meeting_agenda
## End(Not run)
Extract information on specific MPs
Description
A function for retrieving information on Norwegian MPs from the parliament API
Usage
get_mp(mpid = NA, good_manners = 0)
Arguments
mpid |
Character string indicating the id of the MP to retrieve. |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
Value
A data.frame with the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
death | MP date of death, if applicable |
last_name | MP last name |
birth | MP date of birth |
first_name | MP first name |
id | MP id |
gender | MP gender |
See Also
get_mp_bio get_parlperiod_mps get_mp_pic get_session_mp_speech_activity
Examples
## Not run:
# Request one MP by id
get_mp("AAMH")
# Request several MPs by id
ids <- c("AAMH", "AMSK", "MAAA")
mps <- lapply(ids, get_mp, good_manners = 2)
mps <- do.call(rbind, mps)
## End(Not run)
Extract biography of specific MPs
Description
A function for retrieving biography of Norwegian MPs from the parliament API
Usage
get_mp_bio(mpid = NA, good_manners = 0)
Arguments
mpid |
Character string indicating the id of the MP to retrieve. |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
Value
A list with ten data frames:
-
$root (main data on the MP)
response_date Date of data retrieval version Data version from the API id Id of the MP -
$literature (all literature the MP contributed to)
year Year of entry publication description Description of the publication last_name MP's last name more_years Not described in the API publisher Publisher first_name First name of the MP place Place of publication title Title of the publication type MP's role in publication (author etc) -
$leave_of_absence (times the MP was on leave)
from_date Start date of leave reason Reason for leave to_date End of leave type Type of leave sub_last_name Substitute MP last name (id not recorded) sub_first_name Substitute MP first name -
$personalia (the MP's personalia)
seniority_aar Number of years in parliament seniority_dager Number of extra days (addition to years) county_of_birth Birth county of the MP municipality_of_birth Birth municipality of the MP eulogy_date Eulogy date of the MP, when applicable -
$father (the MP's father personalia)
death_year Father's year of death last_name Father's last name birth_year Father's year of birth first_name Father's first name profession Father's profession -
$mother (the MP's mother personalia)
death_year Mother's year of death last_name Mother's last name birth_year Mother's year of birth first_name Mother's first name profession Mother's profession -
$parl_periods (parliamentary periods the MP has held a seat)
from_date Date MP held seat from county County the MP represented party_id Party id for the MP's party rep_number Representative number (within the whol parliament) parl_period_id Id of the parliamentary period to_date Date MP held a seat to type Type of representation -
$parl_positions (parliamentary positions held by the MP)
from_year Year MP held position from from_date Date MP held position from committee_id Id of the position (in committee, cabinet, delegation, etc) committee_name Position name committee_type Position type sorting Not described in the API parl_period_id Parliamentary period the position was held (cabinet data missing) to_year Year MP held position to to_date Date MP held position to -
$vocation (vocation and education of the MP outside of parliament)
several_periods_text Text description if the vocation was held for several periods from_year Year MP held vocation from from_year_unknown Logical indication for whether the start year is unknown note Note for vocation name Name of vocation to_year Year MP held vocation to to_year_unknown Logical indication for whether the end year is unknown type Vocation type (10 = education, 20 = work) -
$other_positions (other positions held outside parliament)
several_periods_text Text description if the vocation was held for several periods (removed from API) from_year Year MP held vocation from from_year_sorting Not described in API (removed from API) from_year_unknown Logical indication for whether the start year is unknown max_to_year The last possible time the MP held the position (removed from API) note Note for position min_to_year The earliest possible time the MP held the position (removed from API) level Not described in API organization Organization holding the position place Place of the position to_year Year MP held position to to_year_unknown Logical indication for whether the end year is unknown type Position type position Position name/description
See Also
get_mp get_parlperiod_mps get_mp_pic get_session_mp_speech_activity
Examples
## Not run:
# Request one MP by id
get_mp_bio("AAMH")
## End(Not run)
Retrieve picture of specific MPs
Description
A function for retrieving Norwegian MP pictures by id.
Usage
get_mp_pic(mpid = NA, size = "middels",
destfile = NA, show_plot = FALSE,
good_manners = 0)
Arguments
mpid |
Character string indicating the id of the MP to retrieve. |
size |
Character string size of the picture. Accepts values "lite" (small), "middels" (medium – default), and "stort" (big). |
destfile |
Character string specifying where to save the picture |
show_plot |
Logical. FALSE (default) if no plot should be produced and TRUE if plot should be produced. Requires the "imager" package. |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
Value
Picture of the requested MP in the preferred size.
See Also
get_mp get_parlperiod_mps get_mp_bio
Examples
## Not run:
# Request one MP by id
get_mp_pic(mpid = "AAMH", destfile = "~/Pictures/AAMH.jpeg", show_plot = TRUE, size = "stort")
# With good manners for multiple calls
lapply(c("AAMH", "CIH", "TKF"), function(x){
get_mp_pic(mpid = x, destfile = paste0("~/Pictures/", x),
show_plot = TRUE, size = "stort", good_manners = 2)
})
## End(Not run)
Get list of MPs in a given parliamentary period
Description
A function for retrieving Norwegian MPs for a given parliamentary period from the parliament API
Usage
get_parlperiod_mps(periodid = NA, substitute = FALSE, good_manners = 0)
Arguments
periodid |
Character string indicating the id of the parliamentary period to retrieve. |
substitute |
Logical. Whether or not to include substitute MPs. |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
Value
A data.frame with the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
death | Date of death |
lastname | MP last name |
birth | Date of birth |
firstname | MP first name |
mp_id | MP id |
gender | MP gender |
county_id | Id of county MP represented |
party_id | Id of party MP represented |
substitute_mp | Logical for whether MP is a substitute |
period_id | Id of period represented in |
See Also
get_mp_bio get_mp get_mp_pic get_session_mp_speech_activity
Examples
## Not run:
# Request one MP by id
get_parlperiod_mps("2005-2009")
# Request MPs from several periods by id
ids <- c("1961-65", "1997-01", "2009-2013")
mps <- lapply(ids, get_parlperiod_mps, good_manners = 2)
mps <- do.call(rbind, mps)
## End(Not run)
Get list of presidency in a given parliamentary period
Description
A function for retrieving the presidency for a given parliamentary period from the parliament API.
Usage
get_parlperiod_presidency(periodid = NA, good_manners = 0)
Arguments
periodid |
Character string indicating the id of the parliamentary period to retrieve. |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
Value
A data.frame with the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
last_name | Last name of presidency member |
first_name | First name of presidency member |
from_date | Presidency member from date |
party_id | Party affiliation of presidency member |
person_id | Id of the presidency member |
to_date | Presidency member to date |
position | Presidency position |
See Also
Examples
## Not run:
# Request one MP by id
get_parlperiod_presidency("2005-2009")
## End(Not run)
Get Parliamentary Periods
Description
A function for retrieving dates of the parliamentary periods after WWII
Usage
get_parlperiods()
Value
A data.frame with the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
from | Date session started |
id | Id of for session (used for other functions) |
to | Date session ended |
years | From year to year in full format |
See Also
Examples
## Not run:
parlper <- get_parlperiods()
parlper
## End(Not run)
Get Parliamentary Sessions
Description
A function for retrieving dates of the parliamentary sessions after WWII
Usage
get_parlsessions()
Value
A data.frame with the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
from | Date session started |
id | Id of for session (used for other functions) |
to | Date session ended |
years | From year to year in full format |
See Also
Examples
## Not run:
parlses <- get_parlsessions()
parlses
## End(Not run)
All parliamentary proceedings
Description
A function for retrieving all proceedings in Stortinget, both current and historical.
Usage
get_proceedings()
Value
A list with three dataframes:
-
$root (only download meta data)
response_date Date of data retrieval version Data version from the API $proceedings (description of main proceeding categories)
id Id of proceeding name Name of proceeding $poceedings_steps (description of proceeding steps within each main category)
id Id of proceeding step name Name of proceeding step step_number Order of proceeding steps outdated Whether the step is outdated main_id Id for proceeding type the step belongs to
Examples
## Not run:
get_proceedings()
## End(Not run)
Retreive all votes for a specified vote proposal
Description
A function for retrieving all votes from a specific vote proposal. Vote data are only available from the 2011-2012 session
Usage
get_proposal_votes(voteid = NA, good_manners = 0)
Arguments
voteid |
Character string indicating the id of the vote to request all votes from |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
Value
A list with two elements:
-
$proposal_vote (main data on the vote proposal)
response_date Date of data retrieval version Data version from the API vote_id Id of the vote -
$proposal_by_parties${proposal_id} (what parties (id) stood behind proposal(s))
See Also
get_vote get_decision_votes get_result_vote
Examples
## Not run:
prop <- get_proposal_votes(7523)
prop
for(i in 1:length(prop$proposal_by_parties)){
prop$proposal_vote$parties[i] <- paste0(prop$proposal_by_parties[[i]],
collapse = ", ")
}
## End(Not run)
Retrieve a specific publication
Description
A function for retrieving a specific publication. Because these are formatted very differently in the API,
the returning object is in a raw html_document format, best manipulated with html node extraction functions
such as rvest::html_elements()
.
Usage
get_publication(publicationid = NA, good_manners = 0)
Arguments
publicationid |
Character string indicating the id of the publication to request all votes from |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
Value
A raw html_document
See Also
get_question get_question_hour get_session_publications
Examples
## Not run:
pub <- get_publication("refs-201819-03-06")
(pub |> html_elements("replikk"))[1] |> html_text()
## End(Not run)
Parliamentary question
Description
A function for retrieving single parliamentary questions by id. For retrieving the whole debate over a question, the get_publication function has to be used
Usage
get_question(questionid = NA, good_manners = 0)
Arguments
questionid |
Character string indicating the id of the session to request interpellations from |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
Value
A data.frame with the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
justification | Justification for question |
answ_by_id | Id for answering minister |
answ_by_minister_id | Id for department of answering minister |
answ_by_minister_title | Title for department of answering minister |
answ_date | Date question was asked |
answ_on_belhalf_of | Id of minister answered on behalf of, when relevant |
answ_on_belhalf_of_minister_id | Id of department answered on behalf of, when relevant |
answ_on_belhalf_of_minister_title | Title of department answered on behalf of, when relevant |
agenda_number | Agenda number in meeting |
moved_to | Date moved to |
id | Question id |
legacy_id | Question legacy id (only use to match with data downloaded before 10.12.2024) |
correct_person_id | Not documented in API |
correct_person_minister_id | Not documented in API |
correct_person_minister_title | Not documented in API |
sendt_date | Date question was sent |
session_id | Session id |
question_text | Full question text |
question_from_id | Id of MP asking the question |
qustion_number | Question number |
qustion_to_id | Id of minister the question was asked to |
qustion_to_minister_id | Department id of minister the question was asked to |
qustion_to_minister_title | Department title of minister the question was asked to |
answer_text | Answer text (often empty) |
title | Question title |
type | Question type |
asked_by_other_id | ID of person that asked the question on behalf of question_from_id |
See Also
get_question_hour get_publication get_meeting_agenda
Examples
## Not run:
# An example of a possible workflow
## Retreive sessions
sessions <- get_parlsessions()
## Retreive all interpellations for a particular session
qsesh <- get_session_questions(sessions$id[9], q_type = "interpellasjoner")
## Retreve detailed information on all interpellations in that session
library(pbmcapply) # for progress bar. never use paralell on scraping
int1213 <- pbmclapply(qsesh$id, function(x){
get_question(x, good_manners = 2)
}, mc.cores = 1)
quest1213 <- do.call(rbind, int1213)
## End(Not run)
Retrieve question hour details for a specified meeting
Description
A function for retrieving detailed overview of the question hour for a specific meeting
Usage
get_question_hour(meetingid = NA, good_manners = 0)
Arguments
meetingid |
Character string indicating the id of the meeting to request all votes from |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
Value
A list with ten data frames:
-
$root (download meta data)
response_date Date of data retrieval version Data version from the API meetingid The called meeting id -
$question_hour_ministers (id of ministers in parliament during question hour/time)
id Id of ministers attending -
$question_time
question_justification Justification for question answer_by_id Id for answering minister answer_by_minister_id Id for department of answering minister answer_by_minister_title Title for department of answering minister answer_date Date of receiving answer answer_on_behalf_of_id Id of minister answered on behalf of, when relevant answer_on_behalf_of_minister_id Id of department answered on behalf of, when relevant answer_on_behalf_of_minister_title Title of department answered on behalf of, when relevant agenda_case_number Case number on agenda date Date question hour was held moved_to Date moved to asked_by_other_id Id for minister asking on behalf of another, when relevant question_id Question id correct_person Not documented in API correct_person_minister_id Not documented in API correct_person_minister_title Not documented in API sent_date Date question was sent session_id Session id question_text Full question text question_from_id Id of MP asking the question question_number Question number question_to_id Id of minister the question was asked to question_to_minister_id Department id of minister the question was asked to question_to_minister_title Department title of minister the question was asked to status Question status answer Answer text (often empty) title Question title type Question type -
$publication_reference
export_id Export id for publication (see get_publication()) link_text Description text for publication link_url URL for publication type Type of publication sub_type Subtype for publication (location)
See Also
get_question get_session_questions get_publication
Examples
## Not run:
get_question_hour(10232)
## End(Not run)
Retrieve vote results on MP level for a specified vote
Description
A function for retrieving vote results from a specific vote on MP level. Vote data are only available from the 2011-2012 session. Needs some preprocessing for use with rollcall packages, such as ideal.
Usage
get_result_vote(voteid = NA, good_manners = 0)
Arguments
voteid |
Character string indicating the id of the vote to request all votes from |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
Value
A data.frame with the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
vote_id | Id of vote |
mp_id | MP id |
party_id | Party id |
vote | Vote: for, mot (against), ikke_tilstede (absent) |
permanent_sub_for | Id of the MP originally holding the seat, if the substitute is permanent |
sub_for | Id of the MP originally holding the seat |
See Also
get_decision_votes get_proposal_votes get_vote get_mp_bio
Examples
## Not run:
v <- get_result_vote(12345)
table(v$vote)
p <- get_proposal_votes(12345)
stringr::str_replace_all(p$proposal_vote$proposal_text,
"\\<(.*)\\>|\\r\\n", "") |>
stringr::str_trim()
## End(Not run)
Cases in specified session
Description
A function for retrieving all cases treated in a specified parliamentary session.
Usage
get_session_cases(sessionid = NA, good_manners = 0, cores = 1)
Arguments
sessionid |
Character string indicating the id of the parliamentary session to retrieve. |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
cores |
Integer. Number of cores (1 by default) to use in structuring the data. More than 1 will not work on windows |
Value
A data.frame with the following variables:
-
$root (main data on the MP)
response_date Date of data retrieval version Data version from the API treated_session_id Session the case was treated in document_group Document group the case belongs to reference Document reference id Case id com_req_id Committee recommendation id com_req_code Committee recommendation code title_short Short title of case case_filed_id Id of filed case last_update_date Date of last update on case status Status of the case title Full title of the case type Type of case session_id Session id of the case committee_id Responsible committee id -
$topics (named list by case id)
is_main_topic Logical indication whether the topic is the main topic main_topic_id Id of the main topic for the case id Topic id name Topic name -
$proposers (named list by case id)
rep_id Proposing MP id county_id County id of proposing MP party_id Party id of proposing MP rep_sub Logical indicator for whether MP is a substitute -
$spokespersons (data frame by case id)
case_id Case id rep_id Spokesperson(s) MP id for the case county_id County id of spokesperson MP party_id Party id of spokesperson MP rep_sub Logical indicator for whether MP is a substitute
See Also
Examples
## Not run:
s0506 <- get_session_cases("2005-2006")
head(s0506)
## End(Not run)
Parliamentary committees in specified session
Description
A function for retrieving Norwegian parliamentary committees for a specified parliamentary session
Usage
get_session_committees(sessionid = NA, good_manners = 0)
Arguments
sessionid |
Character string indicating the id of the parliamentary session to retrieve. |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
Value
A data.frame with the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
id | Committee id |
name | Committee name |
session_id | Session id |
See Also
get_all_committees get_mp_bio get_mp
Examples
## Not run:
coms <- get_session_committees("2001-2002")
coms
## End(Not run)
Retrieve all decisions for a specified session
Description
A function for retrieving all decisions from a specific parliamentary session.
Usage
get_session_decisions(sessionid = NA, good_manners = 0)
Arguments
sessionid |
Character string indicating the id of the session to request all votes from |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
Value
A data.frame with the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
session_id | Session id |
decision_id | Decision id |
case_id | Case id |
case_link_url | URL for case to front end web page |
decision_date | Decision date |
decision_link_url | URL for decision to front end web page |
decision_number | Decision number within session |
decision_text | Decision text |
decision_title | Decision title |
decision_type_id | Decision type id |
decision_type_name | Decision type name |
See Also
Examples
## Not run:
desci <- get_session_decisions("2004-2005")
head(desci)
## End(Not run)
Parliamentary delegations in specified session
Description
A function for retrieving delegations for a specified parliamentary session.
Usage
get_session_delegations(sessionid = NA, good_manners = 0)
Arguments
sessionid |
Character string indicating the id of the parliamentary session to retrieve. |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
Value
A data.frame with the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
id | Delegation id |
name | Name of delegation |
session_id | Session id |
See Also
get_session_committees get_all_committees
Examples
## Not run:
deleg <- get_session_delegations("2015-2016")
deleg
## End(Not run)
Retrieve hearings in specified session
Description
A function for retrieving all hearings in a specified parliamentary session.
Usage
get_session_hearings(sessionid = NA, good_manners = 0, cores = 1)
Arguments
sessionid |
Character string indicating the id of the parliamentary session to retrieve. |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
cores |
Integer... |
Value
A list with four elements:
-
$root (hearing meta data)
response_date Date of data retrieval version Data version from the API session_id Session id -
$hearing (main data on the hearing)
deadline_date Deadline date for hearing status Data version from the API hearing_id Hearing id input_deadline Deadline date for input written Logical indication of whether the input was written application_deadline Deadline date for application to hearing start_date Start date for hearing status_pub Publication status for hearing status_info_text Status information text type Type of hearing committee_id Committee id for committee responsible for hearing -
$hearing_case_info (named list by hearing id with information on the case(s) belonging to the hearing)
hearing_id Hearing id case_reference Text reference for case case_id Case id case_short_title Short title for case case_publication URL for front end web-page publication case_title Full title for case -
$hearing_date (named list by hearing id with date(s) the hearing was held)
hearing_id Hearing id date Date of hearing place Where the hearing was held
See Also
get_hearing_input get_hearing_program get_written_hearing_input
Examples
## Not run:
hear <- get_session_hearings("2010-2011")
head(hear$hearing)
## End(Not run)
Retrieve all meetings for a specified parliamentary session
Description
A function for retrieving meetings from a specific parliamentary session
Usage
get_session_meetings(sessionid = NA, good_manners = 0)
Arguments
sessionid |
Character string indicating the id of the session to request all votes from |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
Value
A data.frame with the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
session_id | Session id |
agenda_number | Agenda number within the session |
footnote | Footnotes for the meeting |
meeting_id | Meeting id |
no_meeting_text | Description of why there was no meeting, if relevant |
evening_meeting | Whether the meeting was an evening meeting or not |
note | Note for the meeting |
meeting_date | Date the meeting took place |
meeting_order | Indicator for meeting order |
meeting_place | Where the meeting took place |
transcript_id | Id for transcript (usually empty) |
additional_agenda | Logical indicator for whether there was additional agenda to the meeting |
See Also
get_meeting_agenda get_question_hour
Examples
## Not run:
meet <- get_session_meetings("2013-2014")
head(meet)
## End(Not run)
Retrieve all speech activity from one MP for a given session
Description
A function for retrieving all speech activity from an MP during a specific parliamentary session. Only available from the 2011-2012 session and onwards.
Usage
get_session_mp_speech_activity(sessionid = NA, mp_id = NA, good_manners = 0)
Arguments
sessionid |
Character string indicating the session to retrieve speeches from. |
mp_id |
Character string for the MP to retreive all speeches of in a given session. |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
Value
A data.frame with the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
session_id | Session id |
agenda_case_number | Number indicating the agenda number for the case |
meeting_id | Meeting id |
speech_start_time | Start time of speech |
speech_type | Type of speech |
speech_length_secs | Lenght of speech in seconds |
See Also
get_mp get_mp_bio get_publication
Examples
## Not run:
activ <- get_session_mp_speech_activity("2012-2013", "ALYS")
head(activ)
## End(Not run)
Parliamentary parties in specified session
Description
A function for retrieving Norwegian parliamentary parties for a specified parliamentary session
Usage
get_session_parties(sessionid = NA, good_manners = 0)
Arguments
sessionid |
Character string indicating the id of the parliamentary session to retrieve. |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
Value
A data.frame with the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
id | Party id |
name | Party name |
represented_party | Logical indication of whether party was represented |
session_id | Session id |
period_id | Parliamentary period id |
See Also
Examples
## Not run:
parties <- get_session_parties("2003-2004")
parties
## End(Not run)
Retrieve publications of a type in a parliamentary session
Description
A function for retrieving one of several publication types within a parliamentary session.
Usage
get_session_publications(sessionid = NA, type = "referat", good_manners = 0)
Arguments
sessionid |
Character string indicating the id of the hearing to retrieve. |
type |
Character specifying type of publication to download. Available types are "referat" (minutes), "innstilling" (proposition), "innberetning" (report), "lovvedtak" (law decision), "lovanmerkning" (law note), "dok8" (MP proposal) "dok12" (Constitutional proposal), and "dokumentserie" (document series). Defaults to "referat". |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
Value
A data.frame with the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
session_id | Session id |
publication_date | Date of publication |
publication_id | Id of publication |
publication_format | Publication format (XML) |
publication_available_date | When the publication was made available |
publication_title | Publication title |
publication_type | Publication type |
See Also
Examples
## Not run:
pub <- get_session_publications("1998-99")
head(pub)
## End(Not run)
Parliamentary questions in a session
Description
A function for retrieving all questions within a parliamentary session.
Usage
get_session_questions(sessionid = NA, q_type = NA, status = NA, good_manners = 0)
Arguments
sessionid |
Character string indicating the id of the session to request interpellations from |
q_type |
Character string indicating type of question to retrieve. Options are "interpellasjoner" (interpellations), "sporretimesporsmal" (oral questions), or "skriftligesporsmal" (written questions). |
status |
Character string question status extraction. Possible values are NA (extract all questions), "til_behandling" (pending questions), "trukket" (withdrawn questions), "bortfalt" (lapsed questions), or "alle" (all questions) |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
Value
A data.frame with the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
answ_by_id | Id of minister answering question |
answ_by_minister_id | Department id of answering minister |
answ_by_minister_title | Department title of answering minister |
answ_date | Date answer was given |
answ_on_belhalf_of | Answer given on behalf of |
answ_on_belhalf_of_minister_id | Department id of minister given answer on behalf of |
answ_on_belhalf_of_minister_title | Department title of minister given answer on behalf of |
topic_ids | Id of relevant topics for question |
moved_to | Question moved to |
asked_by_other_id | MP id, if question was not asked by the questioning MP |
id | Question id |
correct_person | Not documented in API |
correct_person_minister_id | Not documented in API |
correct_person_minister_title | Not documented in API |
sendt_date | Date the question was sent |
session_id | Session id |
question_from_id | Question from MP id |
question_number | Question number within session |
question_to_id | Question directed to minister id |
question_to_minister_id | Question directed to minister department id |
question_to_minister_title | Question directed to minister department title |
status | Question status |
title | Question title |
type | Question type |
See Also
get_question_hour get_question
Examples
## Not run:
interp <- get_session_questions(sessionid = "2013-2014",
q_type = "interpellasjoner",
status = "trukket")
interp
## End(Not run)
Get list of topics and sub-topics for the Norwegian parliament
Description
A function for retrieving topic keys used to label various data from the Norwegian parliament.
Usage
get_topics(keep_sub_topics = TRUE)
Arguments
keep_sub_topics |
Logical. Whether to keep sub-topics (default) for all main topics or not. |
Value
A list with two elements:
-
$topics (All topics)
response_date Date of data retrieval version Data version from the API is_main_topic Logical indicator for whether the topic is a main topic main_topic_id Id of main topic id Id of topic name Name of topic -
$main_topics (exclusively main topics, if keep_sub_topics = TRUE)
response_date Date of data retrieval version Data version from the API is_main_topic Logical indicator for whether the topic is a main topic main_topic_id Id of main topic id Id of topic name Name of topic
Examples
## Not run:
# Request the data
tops <- get_topics()
# Look at the first main topic
tops$main_topics[1, ]
# Extract all sub-topics for the first main topic
tops$topics[which(tops$topics$main_topic_id == 5), ]
## End(Not run)
Retreive votes for a specific case
Description
A function for retrieving all votes from a case. Vote data are only available from the 2011-2012 session
Usage
get_vote(caseid = NA, good_manners = 0)
Arguments
caseid |
Character string indicating the id of the case to request all votes from |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
Value
A data.frame with the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
case_id | Case id up for vote |
alternative_vote | Whether vote is an alternative vote |
n_for | Number of votes for |
n_absent | Number of MPs absent |
n_against | Number of votes against |
treatment_order | Order of treated votes |
agenda_case_number | Case number on the agenda of the meeting |
free_vote | Logical indication of whether the vote is related to the case as a whole |
comment | Vote comment |
meeting_map_number | Number on the meeting map |
personal_vote | Logical indication of whether vote was recorded as roll call or not |
president_id | Id of president holding president chair at the time of voting |
president_party_id | Party of the sitting president |
adopted | Logical indication of whether the proposal voted on was adopted |
vote_id | Id of vote |
vote_method | Voting method |
vote_result_type | Result type (enstemmig_vedtatt = unanimously adopted) |
vote_result_type_text | See vote_result_type |
vote_topic | Description of the proposal voted upon |
vote_datetime | Date and time of vote |
See Also
get_decision_votes get_proposal_votes get_vote get_session_cases get_case
Examples
## Not run:
get_vote(63033)
## End(Not run)
Retrieve written input for a specified hearing
Description
A function for retrieving written input for a specified hearing
Usage
get_written_hearing_input(hearingid = NA, good_manners = 0)
Arguments
hearingid |
Character string indicating the id of the hearing to retrieve. |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
Value
A data.frame the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
hearing_id | Id of the hearing |
hearing_type | Type of hearing |
committee_id | Id of committee responsible for the hearing |
hearing_input_date | Date of receiving input |
hearing_input_id | Hearing input id |
hearing_input_organization | Organization giving input |
hearing_input_text | Full text of the hearing input |
hearing_input_title | Title of the hearing input |
See Also
get_hearing_input get_hearing_program get_session_hearings
Examples
## Not run:
get_written_hearing_input(hearingid = 10004243)
## End(Not run)
Interpellations from the 2002-2003
Description
A dataset containing all interpellations in the 2002-2003 parliamentary session in Stortinget
Usage
interp0203
Format
A data frame with 26 columns and 22 rows
- response_date
Date of data retrieval
- version
Data version from the API
- answ_by_id
Id of minister answering question
- answ_by_minister_id
Department id of answering minister
- answ_by_minister_title
Department title of answering minister
- answ_date
Date answer was given
- answ_on_belhalf_of
Answer given on behalf of
- answ_on_belhalf_of_minister_id
Department id of minister given answer on behalf of
- answ_on_belhalf_of_minister_title
Department title of minister given answer on behalf of
- topic_ids
Id of relevant topics for question
- moved_to
Question moved to
- asked_by_other_id
MP id, if question was not asked by the questioning MP
- id
Question id
- correct_person
Not documented in API
- correct_person_minister_id
Not documented in API
- correct_person_minister_title
Not documented in API
- sendt_date
Date the question was sent
- session_id
Session id
- question_from_id
Question from MP id
- qustion_number
Question number within session
- qustion_to_id
Question directed to minister id
- qustion_to_minister_id
Question directed to minister department id
- qustion_to_minister_title
Question directed to minister department title
- type
Question type
- title
Question title
- status
Question status
Source
https://data.stortinget.no/eksport/interpellasjoner?sesjonid=2002-2003
Members of parliament from the 1945-1949
Description
A dataset containing all MPs during the 1945-1949 parliamentary period in Stortinget
Usage
mps4549
Format
A data frame with 12 columns and 150 rows
- response_date
Date of data retrieval
- version
Data version from the API
- death
Date of death
- lastname
MP last name
- birth
Date of birth
- firstname
MP first name
- mp_id
MP id
- gender
MP gender
- county_id
Id of county MP represented
- party_id
Id of party MP represented
- substitute_mp
Logical for whether MP is a substitute
- period_id
Id of period represented in
Source
https://data.stortinget.no/eksport/representanter?stortingsperiodeid=1945-49
Parliamentary periods
Description
A dataset containing all parliamentary periods in Stortinget
Usage
parl_periods
Format
A data frame with 12 columns and 150 rows
- response_date
Date of data retrieval
- version
Data version from the API
- from
Date session started
- id
Id of for session (used for other functions)
- to
Date session ended
- years
From year to year in full format
Source
https://data.stortinget.no/eksport/stortingsperioder
Parliamentary sessions
Description
A dataset containing all parliamentary sessions in Stortinget
Usage
parl_sessions
Format
A data frame with 6 columns and 36 rows
- response_date
Date of data retrieval
- version
Data version from the API
- from
Date session started
- id
Id of for session (used for other functions)
- to
Date session ended
- years
From year to year in full format
Source
https://data.stortinget.no/eksport/sesjoner
Read Oslo-Bergen-Tagger processed files into R
Description
A function reading OBT-tagged files
Usage
read_obt(file = NA)
Arguments
file |
character. Path to OBT-tagged file |
Value
A data frame with the following variables:
sentence | Sentence number |
index | Token number in sentence |
token | Raw token, as read by OBT originally |
lwr | Lowercase raw token |
lemma | Lemmatized token |
pos | Part of Speech |
morph | Morphological tags |
Examples
## Not run:
sample_text <- read_obt("./inst/extdata/obt_sample.txt")
head(sample_text)
## End(Not run)
Color palette for parties in the Storting
Description
A color palette for all (current) parties in the Storting
Usage
st_party_colors
Format
A vector of party abbreviations and official hex colors
- Arbeiderpartiet (Labour Party)
- Fremskrittspartiet (Progress Party)
https://www.frp.no/files/Grafiske-retningslinjer/FrP-Profilmanual-2023.pdf
- Høyre (Conservative Party)
- Kristelig Folkeparti (Christian Democratic Party)
- Miljøpartiet De Grønne (Green Party)
- Pasientfokus (Patient Focus)
- Rødt (Red Party)
- Senterpartiet (Centre Party)
https://profil.senterpartiet.no/point/no/senterpartietbc/component/default/24406
- Sosialistisk Venstreparti (Socialist Left Party)
- Venstre (Liberal Party)
Source
See list of links above; there are several color alternatives for most parties.
Examples
## Not run:
barplot(table(get_parlperiod_mps(parl_periods$id[1])$party_id), col = st_party_colors)
## End(Not run)
Meta data on votes of case id 78686
Description
A dataset containing vote infomation on case id 78686 in Stortinget
Usage
vote
Format
A list with three elements (votes)
- response_date
Date of data retrieval
- version
Data version from the API
- case_id
Case id up for vote
- alternative_vote
Whether vote is an alternative vote
- n_for
Number of votes for
- n_absent
Number of MPs absent
- n_against
Number of votes against
- treatment_order
Order of treated votes
- agenda_case_number
Case number on the agenda of the meeting
- free_vote
Logical indication of whether the vote is related to the case as a whole
- comment
Vote comment
- meeting_map_number
Number on the meeting map
- personal_vote
Logical indication of whether vote was recorded as roll call or not
- president_id
Id of president holding president chair at the time of voting
- president_party_id
Party of the sitting president
- adopted
Logical indication of whether the proposal voted on was adopted
- vote_id
Id of vote
- vote_method
Voting method
- vote_result_type
Result type (enstemmig_vedtatt = unanimously adopted)
- vote_result_type_text
See vote_result_type
- vote_topic
Description of the proposal voted upon
- vote_datetime
Date and time of vote
Source
https://data.stortinget.no/eksport/voteringsresultat?voteringid=15404
Roll call vote results for vote ids 15404, 15405, and 15406
Description
A dataset containing all personal votes for votes 15404, 15405, and 15406 in Stortinget
Usage
vote_result
Format
A list with one vote per element
- response_date
Date of data retrieval
- version
Data version from the API
- vote_id
Id of vote
- mp_id
MP id
- party_id
Party id
- vote
Vote: for, mot (against), ikke_tilstede (absent)
- permanent_sub_for
Id of the MP originally holding the seat, if the substitute is permanent
- sub_for
Id of the MP originally holding the seat
Source
https://data.stortinget.no/eksport/voteringsresultat?voteringid=15404, https://data.stortinget.no/eksport/voteringsresultat?voteringid=15405, https://data.stortinget.no/eksport/voteringsresultat?voteringid=15406