sp_get_dataset: Retrieve dataset from statnipokladna

View source: R/datasets.R

sp_get_datasetR Documentation

Retrieve dataset from statnipokladna

Description

Downloads ZIP archives for a given dataset. If year or month have length > 1, gets all combinations.

Usage

sp_get_dataset(
  dataset_id,
  year,
  month = 12,
  dest_dir = NULL,
  redownload = FALSE
)

Arguments

dataset_id

A dataset ID. See id column in sp_datasets for a list of available datasets

year

year, numeric vector of length <= 1 (can take multiple values), 2015-2019 for some datasets, 2010-2020 for others. Defaults to 2018. (see Details for how to work with data across time periods.)

month

month, numeric vector of length <= 1 (can take multiple values). Must be between 1 and 12. Defaults to 12. (see Details for how to work with data across time periods.)

dest_dir

character. Directory in which downloaded files will be stored. If left unset, will use the statnipokladna.dest_dir option if the option is set, and tempdir() otherwise. Will be created if it does not exist.

redownload

Redownload even if file has already been downloaded? Defaults to FALSE.

Details

Files are stored in a temp folder as determined by tempdir() or the dest_dir param or the statnipokladna.dest_dir option. and further sorted into subdirectories by dataset, year and month. If saved to tempdir() (the default), downloaded files per session to avoid redownloads.

How data for different time periods is exported differs by dataset. This has significant implications for how you get to usable full-year numbers or time series in different tables. See vignette("statnipokladna") for details on this.

Value

character string with complete paths to downloaded ZIP archives.

See Also

Other Core workflow: add_codelist(), get_codelist(), sp_add_codelist(), sp_get_codelist(), sp_get_table()

Examples

## Not run: 
budget_2018 <- sp_get_dataset("finm", 2018)
budget_mid2018 <- sp_get_dataset("finm", 2018, 6)

## End(Not run)

statnipokladna documentation built on Sept. 11, 2024, 8:08 p.m.