Loading 02_code/230506_MM_OECD_Download_Data.R +2 −1 Original line number Diff line number Diff line Loading @@ -9,8 +9,9 @@ library(ggplot2) library(plotly) # -> 0) load data structure for qna dataset <- "qna" dataset <- "QNA" url <- paste0("https://stats.oecd.org/restsdmx/sdmx.ashx/GetDataStructure/", dataset) url <- paste0("https://stats.oecd.org/restsdmx/sdmx.ashx/GetDataStructure/", dataset, "/all?format=SDMX-ML") data_structure <- readsdmx::read_sdmx(url) data_structure %>% filter(id == c("CL_QNA_SUBJECT"), Loading 02_code/240922_MM_OECD_Download_Test.R 0 → 100644 +27 −0 Original line number Diff line number Diff line readsdmx__read_sdmx <- function (path, destfile = tempfile(fileext = ".xml"), quiet = TRUE, method = "libcurl", mode = "w", ...) { path <- url url "http://stats.oecd.org/restsdmx/sdmx.ashx/GetDataStructure/QNA/all?format=SDMX-ML" destfile <- tempfile(fileext = ".xml") quiet <- TRUE method <- "libcurl" mode <- "w" if (readsdmx:::is_url(path)) { if (!capabilities("libcurl") && method == "libcurl"){ method <- "auto" } # df <- download.file(path, destfile, method, quiet, mode, ...) df <- download.file(path, destfile, method, quiet, mode) stopifnot(df == 0L) path <- destfile } stopifnot(file.exists(path)) path <- normalizePath(path) d <- read_sdmx_(path) as.data.frame(d, stringsAsFactors = FALSE) } Loading
02_code/230506_MM_OECD_Download_Data.R +2 −1 Original line number Diff line number Diff line Loading @@ -9,8 +9,9 @@ library(ggplot2) library(plotly) # -> 0) load data structure for qna dataset <- "qna" dataset <- "QNA" url <- paste0("https://stats.oecd.org/restsdmx/sdmx.ashx/GetDataStructure/", dataset) url <- paste0("https://stats.oecd.org/restsdmx/sdmx.ashx/GetDataStructure/", dataset, "/all?format=SDMX-ML") data_structure <- readsdmx::read_sdmx(url) data_structure %>% filter(id == c("CL_QNA_SUBJECT"), Loading
02_code/240922_MM_OECD_Download_Test.R 0 → 100644 +27 −0 Original line number Diff line number Diff line readsdmx__read_sdmx <- function (path, destfile = tempfile(fileext = ".xml"), quiet = TRUE, method = "libcurl", mode = "w", ...) { path <- url url "http://stats.oecd.org/restsdmx/sdmx.ashx/GetDataStructure/QNA/all?format=SDMX-ML" destfile <- tempfile(fileext = ".xml") quiet <- TRUE method <- "libcurl" mode <- "w" if (readsdmx:::is_url(path)) { if (!capabilities("libcurl") && method == "libcurl"){ method <- "auto" } # df <- download.file(path, destfile, method, quiet, mode, ...) df <- download.file(path, destfile, method, quiet, mode) stopifnot(df == 0L) path <- destfile } stopifnot(file.exists(path)) path <- normalizePath(path) d <- read_sdmx_(path) as.data.frame(d, stringsAsFactors = FALSE) }