Package 'noegletalR'

Title: Tidy Tibbles of Noegletal
Description: Work with data from <https://noegletal.dk> in a tidy manner. Tidy up previously downloaded data or retrieve new data directly from the comfort of R. You can also browse an up-to-date list of available data, including thorough variable descriptions.
Authors: Frederik Larsen [aut, cre, cph]
Maintainer: Frederik Larsen <[email protected]>
License: MIT + file LICENSE
Version: 0.2.0
Built: 2025-03-12 04:14:23 UTC
Source: https://github.com/frlars21/noegletalr

Help Index


Get data from noegletal.dk

Description

Get data from noegletal.dk

Usage

noegletal_get(
  muni_codes = ALLOWED_MUNI_CODES,
  years = ALLOWED_YEARS,
  variable_ids
)

Arguments

muni_codes

Vector of municipality codes

years

Vector of years

variable_ids

Vector of variable IDs

Value

Tidy tibble::tibble() with requested data

Examples

noegletal_get(muni_codes = c(101, 155), years = 2018:2024, variable_ids = c(001))

Transform a csv file from noegletal.dk into a tidy tibble

Description

noegletal_tidy takes as input a csv-file downloaded from noegletal.dk and parses it into a tidy tibble::tibble(). This tibble::tibble() has one row for each municipality-year, a muni_code column, a year column and a column for each variable (as selected on noegletal.dk).

As per the noegletal.dk documentation, cells with a dash - as a value is converted to a 0, while cells with a value of M or U is converted to NA, since these represent missing values.

Usage

noegletal_tidy(file)

Arguments

file

Path to a csv file downloaded from noegletal.dk.

Value

A tidy tibble::tibble() with one row for each municipality-year, and one column for each included variable (nøgletal).

Examples

path_to_file <- system.file("extdata",
                            "nwRap-10Sep2024-101803.csv",
                            package = "noegletalR",
                            mustWork = TRUE)
noegletal_tidy(file = path_to_file)

List the available variables on 'noegletal.dk'

Description

When called, noegletal_vars() will go to 'nøgletal.dk' to retrieve an updated list of available variables (nøgletal) including their definitions and return this data as a tibble::tibble() with a row for each variable and three columns: 'variable_id', 'variable_name', 'variable_definition'.

The primary use of the function is to get the ID's for the variables that a user wishes to retrieve with the noegletal_get() function. Additionally, the function is also useful for probing potential variables (including their definitions) that might be of interest for analysis.

A useful way to browse the list is to run the following code from the RStudio console View(noegletalR::noegletal_vars()) which will open the interactive data viewer in RStudio.

Since the list of variables is retrieved anew on every call, noegletal_vars() can only be executed when connected to the internet. Response caching is on the development roadmap for the noegletalR package, but is not implemented yet and does come with its own set of challenges.

Usage

noegletal_vars()

Value

A tibble::tibble() where each row is a variable and the columns are 'variable_id', 'variable_name' and 'variable_definition'.

Examples

noegletal_vars()