Learn R Programming

restatapi (version 0.10.6)

extract_data: Extract data values from SDMX XML

Description

Extracts the data values from the SDMX XML data file

Usage

extract_data(xml_lf, keep_flags = FALSE, stringsAsFactors = FALSE, bulk = TRUE)

Arguments

xml_lf

an input XML leaf with data series from an SDMX XML file to extract the value and its dimensions from it

keep_flags

a logical value if to extract the observation status (flag) information from the XML file. The default value is FALSE

stringsAsFactors

a logical value. If TRUE the columns are converted to factors. The default is FALSE, in this case the strings are returned as characters.

bulk

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.

Value

a data frame containing the values of an SDMX node: the dimensions, value and the optional flag(s)

Details

It is a sub-function to use in the get_eurostat_data and the get_eurostat_raw functions.

Examples

Run this code
# NOT RUN {
id<-"agr_r_milkpr"
toc<-get_eurostat_toc()
bulk_url<-toc$downloadLink.sdmx[toc$code==id]
if (!is.null(bulk_url)){
  temp<-tempfile()
  download.file(bulk_url,temp)
  sdmx_xml<-xml2::read_xml(unzip(temp, paste0(id,".sdmx.xml")))
  xml_leafs<-xml2::xml_find_all(sdmx_xml,".//data:Series")
  extract_data(xml_leafs[1])
  unlink(temp)
}
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab