R/get_eurostat_dsd.R
get_eurostat_dsd.Rd
Download Data Structure Definition (DSD) of a Eurostat dataset if it is not cached previously.
get_eurostat_dsd(
id,
lang = "en",
cache = TRUE,
update_cache = FALSE,
cache_dir = NULL,
compress_file = TRUE,
verbose = FALSE,
...
)
a character string with the id of the dataset. It is a value from the codename
column of the get_eurostat_toc
function.
a character string either en
, de
or fr
to define the language version for the name column of the DSD. It is used only in the new API. The default is en
- English.
a boolean whether to load/save the DSD from/in the cache or not. The default value is TRUE
, so that the DSD is checked first in the cache and if does not exist then downloaded from Eurostat and cached.
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)
a path to a cache directory. The default is NULL
, in this case the DSD 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=...)
.
a logical whether to compress the RDS-file in caching. Default is TRUE
.
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
If the DSD does not exist it returns NULL
otherwise the result is a table with the 3 columns:
concept | The name of the concepts in the order of the data structure |
code | The possible list of codes under the concept |
name | The name/description of the code |
The DSD is downloaded from Eurostat's website, through the REST API in XML (SDMX-ML) format.
For more information see the detailed documentation of the API.
# \donttest{
if (!(grepl("amzn|-aws|-azure ",Sys.info()['release']))) options(timeout=2)
head(get_eurostat_dsd("med_rd6",lang="de",cache=FALSE,verbose=TRUE))
#>
#> get_eurostat_dsd - API version:2
#>
#> get_eurostat_dsd - Trying to download the DSD from: https://ec.europa.eu/eurostat/api/dissemination/sdmx/2.1/datastructure/ESTAT/med_rd6?references=children
#> get_eurostat_dsd - Warning by the download of the DSD file:
#> URL 'https://ec.europa.eu/eurostat/api/dissemination/sdmx/2.1/datastructure/ESTAT/med_rd6?references=children': Timeout of 2 seconds was reached
#> utils::download.file(dsd_endpoint, temp, dmethod)
#>
#> get_eurostat_dsd - class(temp): character - is.na(temp): FALSE - file.size(temp): 1600210 - temp: /tmp/Rtmp7EeCja/file1ba2ca6ebc4
#> Trying to extract the DSD from: /tmp/Rtmp7EeCja/file1ba2ca6ebc4
#> get_eurostat_dsd - Error during the extraction of the XML from the downloaded DSD file:
#> Premature end of data in tag Name line 3 [77]
#> read_xml.character(temp)
#> get_eurostat_dsd - The dsd_xml is NULL. Please check in a browser the url below. If it provides valid response you can try again to download the DSD.
#> https://ec.europa.eu/eurostat/api/dissemination/sdmx/2.1/datastructure/ESTAT/med_rd6?references=children
#> NULL
options(timeout=60)
# }