extract_data | R Documentation |
Extracts the data values from the SDMX XML data file
extract_data(
xml_lf,
keep_flags = FALSE,
stringsAsFactors = FALSE,
bulk = TRUE,
check_toc = FALSE
)
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 |
stringsAsFactors |
a logical value. If |
bulk |
a logical value with default value |
check_toc |
if the data file was downloaded using the URL from the TOC or not. The default is FALSE means not the TOC link is used. |
It is a sub-function to use in the get_eurostat_data
and the get_eurostat_raw
functions.
a data frame containing the values of an SDMX node: the dimensions, value and the optional flag(s)
id<-"agr_r_milkpr"
toc<-get_eurostat_toc()
bulk_url<-toc$downloadLink.sdmx[toc$code==id]
options(timeout=2)
if (!(is.null(bulk_url))&(!(length(bulk_url)==0))){
temp<-tempfile()
tryCatch({download.file(bulk_url,temp)
sdmx_xml<-xml2::read_xml(unzip(temp,paste0(id,".sdmx.xml"),exdir=tempdir()))
xml_leafs<-xml2::xml_find_all(sdmx_xml,".//data:Series")
extract_data(xml_leafs[1])
unlink(file.path(tempdir(),paste0(id,".sdmx.xml")))})
unlink(temp)
}
options(timeout=60)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.