R/search_eurostat_dsd.R
search_eurostat_dsd.Rd
Search the Data Structure Definition (DSD) of a Eurostat dataset for a given pattern. It returns
the rows where the pattern appears in the code and name column of the output of the get_eurostat_dsd
function.
search_eurostat_dsd(pattern, dsd = NULL, name = TRUE, exact_match = FALSE, ...)
a character string or a vector of character string.
a table containing Data Structure Definition (DSD) of a Eurostat dataset which can be retreived by the get_eurostat_dsd
function.
a boolean with the default value TRUE
, if the search shall look for the pattern in the name of the code.
If the value FALSE
, then only the 'code' column of the DSD will be searched.
a boolean with the default value FALSE
, if the strings provided in pattern
shall be matched exactly as it is or as a pattern.
additional arguments to the grep
function like ignore.case=TRUE
if the pattern should be searched case sensitive or not.
The default value for ignore.case
is FALSE
.
If the pattern found then the function returns a data.frame with the 4 columns:
pattern | The pattern which was searched |
concept | The name of the concepts in the data structure |
code | The list of codes where the pattern was found, or the code of a name where the pattern appears |
name | The name/description of the code where the pattern found, or the name of the code where the pattern appears |
Otherwise returns the value NULL
.
The function returns the line(s) where the searched pattern appears in the code or in the name column.
# \donttest{
if (!(grepl("amzn|-aws|-azure ",Sys.info()['release']))) options(timeout=2)
dsd_example<-get_eurostat_dsd("nama_10_gdp",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/nama_10_gdp?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/nama_10_gdp?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): 1682930 - temp: /tmp/Rtmp7EeCja/file1ba52d751c9
#> Trying to extract the DSD from: /tmp/Rtmp7EeCja/file1ba52d751c9
#> get_eurostat_dsd - Error during the extraction of the XML from the downloaded DSD file:
#> Specification mandates value for attribute urn [41]
#> 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/nama_10_gdp?references=children
search_eurostat_dsd("EU",dsd_example)
#> No DSD were provided.
#> NULL
search_eurostat_dsd("EU",dsd_example,ignore.case=TRUE)
#> No DSD were provided.
#> NULL
search_eurostat_dsd("EU27_2019",dsd_example,name=FALSE)
#> No DSD were provided.
#> NULL
search_eurostat_dsd("EU27_2019",dsd_example,exact_match=TRUE)
#> No DSD were provided.
#> NULL
options(timeout=60)
# }