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, ...)

Arguments

pattern

a character string or a vector of character string.

dsd

a table containing Data Structure Definition (DSD) of a Eurostat dataset which can be retreived by the get_eurostat_dsd function.

name

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.

exact_match

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.

Value

If the pattern found then the function returns a data.frame with the 4 columns:

patternThe pattern which was searched
conceptThe name of the concepts in the data structure
codeThe list of codes where the pattern was found, or the code of a name where the pattern appears
nameThe name/description of the code where the pattern found, or the name of the code where the pattern appears

Otherwise returns the value NULL.

Details

The function returns the line(s) where the searched pattern appears in the code or in the name column.

Examples

# \dontshow{
if (parallel::detectCores()<=2){
   options(restatapi_cores=1)
}else{
   options(restatapi_cores=2)
}    
cfg<-get("cfg",envir=restatapi::.restatapi_env) 
rav<-get("rav",envir=restatapi::.restatapi_env)
# }
# \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): 1662976 - temp: /tmp/Rtmp2iECG6/file1b0192d604f
#> Trying to extract the DSD from: /tmp/Rtmp2iECG6/file1b0192d604f
#> get_eurostat_dsd - Error during the extraction of the XML from the downloaded DSD file:
#> Premature end of data in tag AnnotationType line 4 [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/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)
# }