Extracts the data values from the SDMX XML data file
extract_data(xml_lf, keep_flags = FALSE, stringsAsFactors = FALSE, bulk = TRUE)an input XML leaf with data series from an SDMX XML file to extract the value and its dimensions from it
a logical value if to extract the observation status (flag) information from the XML file. The default value is FALSE
a logical value. If TRUE the columns are converted to factors. The default is FALSE,
in this case the strings are returned as characters.
a logical value with default value TRUE if the input SDMX XML file is from the bulk download facility containing all the observations.
If the input file has pre-filtered values then the value FALSE should be used.
a data frame containing the values of an SDMX node: the dimensions, value and the optional flag(s)
It is a sub-function to use in the get_eurostat_data and the get_eurostat_raw functions.
# \donttest{
id<-"agr_r_milkpr"
url<-paste0("https://ec.europa.eu/eurostat/api/dissemination/sdmx/2.1/data/",
id,
"?format=sdmx_2.1_structured&compressed=true")
if (!(grepl("amzn|-aws|-azure ",Sys.info()['release']))) options(timeout=2)
sdmx_xml<-get_compressed_sdmx(url,verbose=TRUE)
#>
#> get_compressed_sdmx - url:https://ec.europa.eu/eurostat/api/dissemination/sdmx/2.1/data/agr_r_milkpr?format=sdmx_2.1_structured&compressed=true
#> get_compressed_sdmx - format:gz
#> get_compressed_sdmx - xml NULL:FALSE
xml_leafs<-xml2::xml_find_all(sdmx_xml,".//Series")
extract_data(xml_leafs[1])
#> geo milkitem freq dairyprod TIME_PERIOD OBS_VALUE
#> 1 AL PRO A D1110A 2021 859.38
#> 2 AL PRO A D1110A 2022 824.94
#> 3 AL PRO A D1110A 2023 765.35
#> 4 AL PRO A D1110A 2024 744.69
options(timeout=60)
# }