Download codelist of a concept from Eurostat if it is not cached previously.

get_eurostat_codelist(
  id,
  lang = "en",
  cache = TRUE,
  update_cache = FALSE,
  cache_dir = NULL,
  compress_file = TRUE,
  verbose = FALSE,
  ...
)

Arguments

id

a character string with id of the concept. It is a value from the concept column of the get_eurostat_dsd function.

lang

a character string either en, de or fr to define the language version for the name column of the codelist. It is used only in the new API. The default is en - English.

cache

a boolean whether to load/save the TOC from/in the cache or not. The default value is TRUE, so that the TOC is checked first in the cache and if does not exist then downloaded from Eurostat and cached.

update_cache

a boolean to update cache or not. The default value is FALSE, so the cache is not updated. Can be set also with options(restatapi_update=TRUE)

cache_dir

a path to a cache directory. The default is NULL, in this case the TOC is cached in the memory (in the '.restatapi_env'). Otherwise if the cache_dir directory does not exist it creates the 'restatapi' directory in the temporary directory from tempdir() to save the RDS-file. Directory can also be set with option(restatapi_cache_dir=...).

compress_file

a logical whether to compress the RDS-file in caching. Default is TRUE.

verbose

A boolean with default FALSE, so detailed messages (for debugging) will not printed. Can be set also with options(restatapi_verbose=TRUE)

...

parameter to pass on the load_cfg function

Value

If the codelist does not exist it returns NULL otherwise the result is a table with the 2 columns:

codeAll the possible codes under the concept
nameThe name/description of the code

Details

The codelist is downloaded from Eurostat's website, through the REST API in XML (SDMX-ML) format.

References

For more information see the detailed documentation of the API.

See also

Examples

if (!(grepl("amzn|-aws|-azure ",Sys.info()['release']))) options(timeout=2)
get_eurostat_codelist("freq",lang="de",cache=FALSE,verbose=TRUE)
#> 
#> get_eurostat_codelist - API version:2
#> get_eurostat_codelist - API version:2
#> 
#> get_eurostat_codelist - Trying to download the codelist from: https://ec.europa.eu/eurostat/api/dissemination/sdmx/2.1/codelist/ESTAT/FREQ
#> Trying to extract the codelist from: /tmp/Rtmp7EeCja/file1ba45c5de92
#> get_eurostat_codelist - codelist NULL:TRUE
#>       code                           name
#>     <char>                         <char>
#>  1:      P                     Mehrjährig
#>  2:      A                       Jährlich
#>  3:      S     Halbjährlich, pro Semester
#>  4:      Q                Vierteljährlich
#>  5:      M                      Monatlich
#>  6:      W                    Wöchentlich
#>  7:      B   Täglich - pro Geschäftswoche
#>  8:      D                        Täglich
#>  9:      H                      Stündlich
#> 10:      I Unregelmäßig / Nichtperiodisch
#> 11:    NAP               Nicht zutreffend
options(timeout=60)