Skip to contents

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:

  1. $topics (All topics)

    response_dateDate of data retrieval
    versionData version from the API
    is_main_topicLogical indicator for whether the topic is a main topic
    main_topic_idId of main topic
    idId of topic
    nameName of topic
  2. $main_topics (exclusively main topics, if keep_sub_topics = TRUE)

    response_dateDate of data retrieval
    versionData version from the API
    is_main_topicLogical indicator for whether the topic is a main topic
    main_topic_idId of main topic
    idId of topic
    nameName of topic

Examples


# Request the data
tops <- get_topics()

# Look at the first main topic
tops$main_topics[1, ]
#>                       response_date version is_main_topic main_topic_id id
#> 1 2024-04-17T13:01:04.5003696+02:00     1.6          true             5  5
#>         name
#> 1 ARBEIDSLIV

# Extract all sub-topics for the first main topic
tops$topics[which(tops$topics$main_topic_id == 5), ]
#>                       response_date version is_main_topic main_topic_id  id
#> 1 2024-04-17T13:01:04.5159872+02:00     1.6         false             5 205
#> 2 2024-04-17T13:01:04.5159872+02:00     1.6         false             5  94
#> 3 2024-04-17T13:01:04.5159872+02:00     1.6         false             5  95
#> 4 2024-04-17T13:01:04.5159872+02:00     1.6         false             5   7
#>              name
#> 1    ARBEIDSMILJØ
#> 2   ARBEIDSVILKÅR
#> 3 LØNN OG INNTEKT
#> 4   SYSSELSETTING