We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
# Title: Country metadata and EA/EU compositions # Author: Sebastian Weinand # Date: 20 December 2023 # load packages: library(openxlsx) library(data.table) # countries: countries <- as.data.table(read.xlsx("U:/HICP/R/package/hicp/dev/countries.xlsx", detectDates=TRUE)) vars <- c("is_eu","is_ea","is_efta","is_candidate") countries[, (vars) := lapply(.SD, as.logical), .SDcols=vars] countries[, "produces_hicp" := !is.na(index_dec_publ) & is.na(eu_until)] # EU composition of the reference period: EU <- list( "code"="EU", "name_en"="European Union", "name_fr"="Union européenne", "name_de"="Europäische Union", "index_decimals"=2L, "composition"=dt[is_eu==TRUE, code]) # euro area composition of the reference period: EA <- list( "code"="EA", "name_en"="Euro area", "name_fr"="Zone euro", "name_de"="Euroraum", "index_decimals"=2L, "composition"=dt[is_ea==TRUE, code]) # get special aggregates: library(xml2) doc <- read_xml("http:https://publications.europa.eu/resource/authority/ed1/ecoicop/B") sa.urls <- xml_attr(x = xml_find_all(doc, xpath="https://skos:member"), attr="resource") sa.codes <- sapply(X=strsplit(sa.urls, split="/", fixed=TRUE), FUN=function(z) z[length(z)]) SPECAGGS <- vector(mode="list", length=length(sa.urls)) for(j in seq_along(SPECAGGS)){ cat("processing url", j, "/", length(SPECAGGS), "\r") sa <- read_xml(x=sa.urls[j]) SPECAGGS[[j]]$code <- sa.codes[j] xpath <- paste0("//rdf:Description[contains(@rdf:about, '", sa.codes[j], "')]") xml.node <- xml_find_all(sa, xpath=xpath) SPECAGGS[[j]]$name_en <- xml_text(xml_find_all(xml.node, xpath="skos:prefLabel[@xml:lang='en']")) SPECAGGS[[j]]$name_fr <- xml_text(xml_find_all(xml.node, xpath="skos:prefLabel[@xml:lang='fr']")) SPECAGGS[[j]]$name_de <- xml_text(xml_find_all(xml.node, xpath="skos:prefLabel[@xml:lang='de']")) comp <- xml_attr(xml_find_all(xml.node, xpath="skos:member"), "resource") SPECAGGS[[j]]$composition <- sapply(X=strsplit(comp, split="/", fixed=TRUE), FUN=function(z) z[length(z)]) Sys.sleep(runif(n=1, min=0.1, max=0.5)) }
The text was updated successfully, but these errors were encountered:
66d7d8f
sweinand
No branches or pull requests
The text was updated successfully, but these errors were encountered: