diff --git a/DESCRIPTION b/DESCRIPTION index 6b56847..259e7a1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -51,5 +51,5 @@ Collate: SDMXRequestBuilder-methods.R SDMXREST20RequestBuilder-methods.R SDMXREST21RequestBuilder-methods.R SDMXDotStatRequestBuilder-methods.R SDMXServiceProvider-methods.R SDMXServiceProviders-methods.R readSDMX.R saveSDMX.R profile.R rsdmx.R -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 Roxygen: list(r6 = FALSE) diff --git a/NAMESPACE b/NAMESPACE index a50f133..668d556 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,131 +1,24 @@ -import("methods") -import("XML") -import("httr") -import("R6") -importFrom("plyr", "rbind.fill") -importFrom("utils", "packageVersion") +# Generated by roxygen2: do not edit by hand -exportClasses( - SDMX, - SDMXSchema, - SDMXHeader, - SDMXFooterMessage, - SDMXFooter, - SDMXType, - SDMXStructureType, - SDMXConcept, - SDMXConceptScheme, - SDMXConcepts, - SDMXCode, - SDMXCodelist, - SDMXCodelists, - SDMXDimension, - SDMXTimeDimension, - SDMXPrimaryMeasure, - SDMXAttribute, - SDMXComponents, - SDMXDataStructure, - SDMXDataStructures, - SDMXDataStructureDefinition, - SDMXItemScheme, - SDMXOrganisationScheme, - SDMXOrganisation, - SDMXAgency, - SDMXAgencyScheme, - SDMXOrganisationSchemes, - SDMXData, - SDMXGenericData, - SDMXCompactData, - SDMXUtilityData, - SDMXStructureSpecificData, - SDMXStructureSpecificTimeSeriesData, - SDMXCrossSectionalData, - SDMXMessageGroup, - SDMXDataFlow, - SDMXDataFlows, - SDMXRequestParams, - SDMXRequestBuilder, - SDMXREST20RequestBuilder, - SDMXREST21RequestBuilder, - SDMXDotStatRequestBuilder, - SDMXServiceProvider, - SDMXServiceProviders -) - -export( - rsdmxLogger, - SDMX, - SDMXSchema, - SDMXHeader, - SDMXFooterMessage, - SDMXFooter, - SDMXType, - SDMXStructureType, - SDMXConcept, - SDMXConceptScheme, - SDMXConcepts, - SDMXCode, - SDMXCodelist, - SDMXCodelists, - SDMXDimension, - SDMXTimeDimension, - SDMXPrimaryMeasure, - SDMXAttribute, - SDMXComponents, - SDMXDataStructure, - SDMXDataStructures, - SDMXDataStructureDefinition, - SDMXOrganisation, - SDMXAgency, - SDMXAgencyScheme, - SDMXOrganisationSchemes, - SDMXGenericData, - SDMXCompactData, - SDMXUtilityData, - SDMXStructureSpecificData, - SDMXCrossSectionalData, - SDMXMessageGroup, - SDMXData, - SDMXDataFlow, - SDMXDataFlows, - SDMXRequestParams, - SDMXRequestBuilder, - SDMXREST20RequestBuilder, - SDMXREST21RequestBuilder, - SDMXDotStatRequestBuilder, - SDMXServiceProvider, - SDMXServiceProviders, - namespaces.SDMX, - findNamespace, - isSoapRequestEnvelope, - getSoapRequestResult, - isRegistryInterfaceEnvelope, - getRegistryInterfaceResult, - addSDMXServiceProvider, - findSDMXServiceProvider, - setSDMXServiceProviders, - getSDMXServiceProviders, - readSDMX, - saveSDMX -) - -exportMethods( - getStructureType, - getNamespaces, - setDSD -) - -S3method(as.data.frame, SDMXGenericData) -S3method(as.data.frame, SDMXCompactData) -S3method(as.data.frame, SDMXUtilityData) -S3method(as.data.frame, SDMXStructureSpecificData) -S3method(as.data.frame, SDMXStructureSpecificTimeSeriesData) -S3method(as.data.frame, SDMXCrossSectionalData) -S3method(as.data.frame, SDMXMessageGroup) -S3method(as.data.frame, SDMXConcepts) -S3method(as.data.frame, SDMXCodelists) -S3method(as.data.frame, SDMXDataStructures) -S3method(as.data.frame, SDMXOrganisationSchemes) -S3method(as.data.frame, SDMXComponents) -S3method(as.data.frame, SDMXDataFlows) -S3method(as.data.frame, SDMXServiceProviders) \ No newline at end of file +S3method(as.data.frame,SDMXCodelists) +S3method(as.data.frame,SDMXCompactData) +S3method(as.data.frame,SDMXComponents) +S3method(as.data.frame,SDMXConcepts) +S3method(as.data.frame,SDMXCrossSectionalData) +S3method(as.data.frame,SDMXDataFlows) +S3method(as.data.frame,SDMXDataStructures) +S3method(as.data.frame,SDMXGenericData) +S3method(as.data.frame,SDMXMessageGroup) +S3method(as.data.frame,SDMXOrganisationSchemes) +S3method(as.data.frame,SDMXServiceProviders) +S3method(as.data.frame,SDMXStructureSpecificData) +S3method(as.data.frame,SDMXStructureSpecificTimeSeriesData) +S3method(as.data.frame,SDMXUtilityData) +export(getStructureType) +export(rsdmxLogger) +import(R6) +import(XML) +import(httr) +import(methods) +import(plyr) +import(utils) diff --git a/R/SDMX-methods.R b/R/SDMX-methods.R index 1c14f62..a82518c 100644 --- a/R/SDMX-methods.R +++ b/R/SDMX-methods.R @@ -64,6 +64,7 @@ encodeSDMXOutput <- function(df){ #' @name getNamespaces #' @docType methods +#' @rdname SDMXStructureType-methods #' @aliases getNamespaces,SDMX-method #' @title getNamespaces #' @description Access the namespaces of the SDMX-ML object @@ -76,11 +77,10 @@ encodeSDMXOutput <- function(df){ #' @seealso \link{SDMX-class} #' #' @author Emmanuel Blondel, \email{emmanuel.blondel1@@gmail.com} +setGeneric("getNamespaces", function(obj) standardGeneric("getNamespaces")); -if (!isGeneric("getNamespaces")) - setGeneric("getNamespaces", function(obj) standardGeneric("getNamespaces")); - -#' @describeIn getNamespaces Access the namespaces of the SDMX-ML object +#' @rdname SDMXStructureType-methods +#' @aliases getNamespaces,SDMX,ANY-method setMethod(f = "getNamespaces", signature = "SDMX", function(obj){ return(namespaces.SDMX(obj@xmlObj)); }) diff --git a/R/SDMXCodelists-methods.R b/R/SDMXCodelists-methods.R index 14e3705..4d6cf54 100644 --- a/R/SDMXCodelists-methods.R +++ b/R/SDMXCodelists-methods.R @@ -53,6 +53,7 @@ codelists.SDMXCodelists <- function(xmlObj, namespaces){ #as.data.frame #============= +#'@export as.data.frame.SDMXCodelists <- function(x, ..., codelistId = NULL, ignore.empty.slots = TRUE){ diff --git a/R/SDMXCompactData-methods.R b/R/SDMXCompactData-methods.R index e573dc5..d6d0e7a 100644 --- a/R/SDMXCompactData-methods.R +++ b/R/SDMXCompactData-methods.R @@ -151,7 +151,7 @@ getSDMXAllCompactData <- function(x, nsExpr, labels = FALSE, ...) { return(encodeSDMXOutput(dataset)) } - +#'@export as.data.frame.SDMXCompactData <- function(x, row.names=NULL, optional=FALSE, labels = FALSE, ...){ return(getSDMXAllCompactData(x, nsExpr = "compact", labels = labels)); diff --git a/R/SDMXComponents-methods.R b/R/SDMXComponents-methods.R index 8c4b0f8..e89a193 100644 --- a/R/SDMXComponents-methods.R +++ b/R/SDMXComponents-methods.R @@ -131,6 +131,7 @@ attributes.SDMXComponents <- function(xmlObj, namespaces){ } #methods +#'@export as.data.frame.SDMXComponents <- function(x, ...){ #dimensions diff --git a/R/SDMXConcepts-methods.R b/R/SDMXConcepts-methods.R index 181b2c9..61b7cb2 100644 --- a/R/SDMXConcepts-methods.R +++ b/R/SDMXConcepts-methods.R @@ -67,6 +67,7 @@ conceptSchemes.SDMXConcepts <- function(xmlObj, namespaces){ #as.data.frame #============= +#'@export as.data.frame.SDMXConcepts <- function(x, ..., conceptSchemeId = NULL, ignore.empty.slots = TRUE){ diff --git a/R/SDMXCrossSectionalData-methods.R b/R/SDMXCrossSectionalData-methods.R index f6ca80e..15efd44 100644 --- a/R/SDMXCrossSectionalData-methods.R +++ b/R/SDMXCrossSectionalData-methods.R @@ -19,7 +19,7 @@ SDMXCrossSectionalData <- function(xmlObj, namespaces){ #methods #======= - +#'@export as.data.frame.SDMXCrossSectionalData <- function(x, row.names=NULL, optional=FALSE, labels = FALSE, ...){ diff --git a/R/SDMXData-methods.R b/R/SDMXData-methods.R index 4713a31..38463f2 100644 --- a/R/SDMXData-methods.R +++ b/R/SDMXData-methods.R @@ -124,6 +124,7 @@ addLabels.SDMXData <- function(data, dsd){ #' @name setDSD #' @docType methods +#' @rdname SDMXData-method #' @aliases setDSD,SDMXData-method #' @title setDSD #' @description set the 'dsd' slot of a \code{SDMXData} object @@ -136,11 +137,10 @@ addLabels.SDMXData <- function(data, dsd){ #' @seealso \link{SDMXData-class} #' #' @author Emmanuel Blondel, \email{emmanuel.blondel1@@gmail.com} +setGeneric("setDSD", function(obj, dsd) standardGeneric("setDSD")); -if (!isGeneric("setDSD")) - setGeneric("setDSD", function(obj, dsd) standardGeneric("setDSD")); - -#' @describeIn setDSD set the 'dsd' slot of a \code{SDMXData} object +#' @rdname SDMXStructureType-methods +#' @aliases setDSD,SDMXData,ANY-method setMethod(f = "setDSD", signature = "SDMXData", function(obj, dsd){ slot(obj, "dsd") <- dsd return(obj) diff --git a/R/SDMXDataFlows-methods.R b/R/SDMXDataFlows-methods.R index 2606d50..2423e2f 100644 --- a/R/SDMXDataFlows-methods.R +++ b/R/SDMXDataFlows-methods.R @@ -58,6 +58,7 @@ dataflows.SDMXDataFlows <- function(xmlObj, namespaces){ } #methods +#'@export as.data.frame.SDMXDataFlows <- function(x, ...){ out <- do.call("rbind.fill", diff --git a/R/SDMXDataStructures-methods.R b/R/SDMXDataStructures-methods.R index dcfb284..8adcfed 100644 --- a/R/SDMXDataStructures-methods.R +++ b/R/SDMXDataStructures-methods.R @@ -51,6 +51,7 @@ datastructures.SDMXDataStructures <- function(xmlObj, namespaces){ } #methods +#'@export as.data.frame.SDMXDataStructures <- function(x, ...){ out <- do.call("rbind.fill", diff --git a/R/SDMXDotStatRequestBuilder-methods.R b/R/SDMXDotStatRequestBuilder-methods.R index 9277d5d..bc7b30b 100644 --- a/R/SDMXDotStatRequestBuilder-methods.R +++ b/R/SDMXDotStatRequestBuilder-methods.R @@ -43,7 +43,7 @@ SDMXDotStatRequestBuilder <- function(regUrl, repoUrl, accessKey = NULL, #resource handler handler <- list( - #'dataflow' resource (path="GetKeyFamily/{resourceID}") + #dataflow resource (path="GetKeyFamily/resourceID") #------------------------------------------------------ dataflow = function(obj){ if(is.null(obj@resourceId)) obj@resourceId = "ALL" @@ -62,7 +62,7 @@ SDMXDotStatRequestBuilder <- function(regUrl, repoUrl, accessKey = NULL, return(req) }, - #'datastructure' resource (path="GetDataStructure/{resourceID}/{agencyID}") + #datastructure resource (path="GetDataStructure/resourceID/agencyID") #-------------------------------------------------------------------------- datastructure = function(obj){ if(is.null(obj@resourceId)) obj@resourceId = "all" @@ -83,7 +83,7 @@ SDMXDotStatRequestBuilder <- function(regUrl, repoUrl, accessKey = NULL, return(req) }, - #'data' resource (path="GetData/{flowRef}/{key}/{agencyId}") + #data resource (path="GetData/flowRef/key/agencyId") #---------------------------------------------------------- data = function(obj){ if(is.null(obj@flowRef)) stop("Missing flowRef value") diff --git a/R/SDMXGenericData-methods.R b/R/SDMXGenericData-methods.R index 7c503db..178cede 100644 --- a/R/SDMXGenericData-methods.R +++ b/R/SDMXGenericData-methods.R @@ -18,6 +18,7 @@ SDMXGenericData <- function(xmlObj, namespaces){ } #methods +#'@export as.data.frame.SDMXGenericData <- function(x, row.names=NULL, optional=FALSE, labels = FALSE, ...){ xmlObj <- x@xmlObj; diff --git a/R/SDMXMessageGroup-methods.R b/R/SDMXMessageGroup-methods.R index ef5f508..5aee534 100644 --- a/R/SDMXMessageGroup-methods.R +++ b/R/SDMXMessageGroup-methods.R @@ -65,6 +65,7 @@ class.SDMXMessageGroup <- function(xmlObj){ } +#'@export as.data.frame.SDMXMessageGroup <- function(x, row.names=NULL, optional=FALSE, labels = FALSE, ...){ #TODO support for other included message types diff --git a/R/SDMXOrganisationSchemes-methods.R b/R/SDMXOrganisationSchemes-methods.R index c25db5a..0464134 100644 --- a/R/SDMXOrganisationSchemes-methods.R +++ b/R/SDMXOrganisationSchemes-methods.R @@ -43,6 +43,7 @@ organisationSchemes.SDMXOrganisationSchemes <- function(xmlObj, namespaces){ } #methods +#'@export as.data.frame.SDMXOrganisationSchemes <- function(x, ...){ out <- do.call("rbind.fill", diff --git a/R/SDMXServiceProvider-methods.R b/R/SDMXServiceProvider-methods.R index c4524f0..dc87749 100644 --- a/R/SDMXServiceProvider-methods.R +++ b/R/SDMXServiceProvider-methods.R @@ -337,7 +337,7 @@ setSDMXServiceProviders <- function(){ # nocov start ), handler = list( - #'dataflow' resource (path="dataset/{resourceId}/def.sdmx.xml") + #dataflow resource (path="dataset/resourceId/def.sdmx.xml") #----------------------------------------------------------------------- dataflow = function(obj){ req <- sprintf("%s/dataset", obj@regUrl) @@ -345,7 +345,7 @@ setSDMXServiceProviders <- function(){ # nocov start req <- paste(req, "def.sdmx.xml", sep="/") return(req) }, - #'datastructure' resource (path="dataset/{resourceID}.structure.sdmx.xml") + #datastructure resource (path="dataset/resourceID.structure.sdmx.xml") #----------------------------------------------------------------------- datastructure = function(obj){ req <- sprintf("%s/dataset", obj@regUrl) @@ -354,7 +354,7 @@ setSDMXServiceProviders <- function(){ # nocov start req <- paste0(req, ".structure.sdmx.xml") return(req) }, - #'data' resource (path="dataset/{resourceID}.generic.sdmx.xml") + #data resource (path="dataset/resourceID.generic.sdmx.xml") #---------------------------------------------------------- data = function(obj){ req <- sprintf("%s/dataset", obj@repoUrl) @@ -393,18 +393,18 @@ setSDMXServiceProviders <- function(){ # nocov start ), handler = list( - #'dataflow' resource (path="/") + #dataflow resource (path="/") #----------------------------------------------------------------------- dataflow = function(obj){ return(obj@regUrl) }, - #'datastructure' resource (path="/{resourceID}) + #datastructure resource (path="/resourceID) #----------------------------------------------------------------------- datastructure = function(obj){ req <- paste(obj@regUrl, obj@resourceId, sep = "/") return(req) }, - #'data' resource (path="getdata?dataflow={flowRef}&key={key}) + #data resource (path="getdata?dataflow=flowRef&key=key) #---------------------------------------------------------- data = function(obj){ if(is.null(obj@flowRef)) stop("Missing flowRef value") @@ -520,18 +520,18 @@ setSDMXServiceProviders <- function(){ # nocov start ), handler = list( - #'dataflow' resource (path="/") + #dataflow resource (path="/") #----------------------------------------------------------------------- dataflow = function(obj){ return(obj@regUrl) }, - #'datastructure' resource (path="/{resourceID}) + #datastructure resource (path="/resourceID) #----------------------------------------------------------------------- datastructure = function(obj){ req <- paste(obj@regUrl, obj@resourceId, sep = "/") return(req) }, - #'data' resource (path="getdata?dataflow={flowRef}&key={key}) + #data resource (path="getdata?dataflow=flowRef&key=key) #---------------------------------------------------------- data = function(obj){ if(is.null(obj@flowRef)) stop("Missing flowRef value") diff --git a/R/SDMXServiceProviders-methods.R b/R/SDMXServiceProviders-methods.R index 7e9e101..92cd1dd 100644 --- a/R/SDMXServiceProviders-methods.R +++ b/R/SDMXServiceProviders-methods.R @@ -13,6 +13,7 @@ SDMXServiceProviders <- function(providers) { new("SDMXServiceProviders", providers = providers); } +#'@export as.data.frame.SDMXServiceProviders <- function(x, ...){ out <- as.data.frame(do.call("rbind", lapply(slot(x, "providers"), diff --git a/R/SDMXStructureSpecificData-methods.R b/R/SDMXStructureSpecificData-methods.R index 48e02a3..0d313c6 100644 --- a/R/SDMXStructureSpecificData-methods.R +++ b/R/SDMXStructureSpecificData-methods.R @@ -19,7 +19,7 @@ SDMXStructureSpecificData <- function(xmlObj, namespaces){ #methods #======= - +#'@export as.data.frame.SDMXStructureSpecificData <- function(x, row.names=NULL, optional=FALSE, labels = FALSE, ...){ return(getSDMXAllCompactData(x, nsExpr = "structurespecific", labels = labels)); diff --git a/R/SDMXStructureSpecificTimeSeriesData-methods.R b/R/SDMXStructureSpecificTimeSeriesData-methods.R index b18287b..6072242 100644 --- a/R/SDMXStructureSpecificTimeSeriesData-methods.R +++ b/R/SDMXStructureSpecificTimeSeriesData-methods.R @@ -19,7 +19,7 @@ SDMXStructureSpecificTimeSeriesData <- function(xmlObj, namespaces){ #methods #======= - +#'@export as.data.frame.SDMXStructureSpecificTimeSeriesData <- function(x, row.names=NULL, optional=FALSE, labels = FALSE, ...){ return(getSDMXAllCompactData(x, nsExpr = "structurespecific", labels = labels)); diff --git a/R/SDMXStructureType-methods.R b/R/SDMXStructureType-methods.R index 333d952..42b0632 100644 --- a/R/SDMXStructureType-methods.R +++ b/R/SDMXStructureType-methods.R @@ -76,10 +76,14 @@ type.SDMXStructureType <- function(xmlObj, namespaces, resource){ } #generics -if (!isGeneric("getStructureType")) - setGeneric("getStructureType", function(obj) standardGeneric("getStructureType")); +#' @export +#' @docType methods +#' @rdname SDMXStructureType-methods +setGeneric("getStructureType", function(obj) standardGeneric("getStructureType")); #methods +#' @rdname SDMXStructureType-methods +#' @aliases getStructureType,SDMXStructureType,ANY-method setMethod(f = "getStructureType", signature = "SDMXStructureType", function(obj){ return(obj@subtype) }) diff --git a/R/SDMXUtilityData-methods.R b/R/SDMXUtilityData-methods.R index 467eb51..7b49694 100644 --- a/R/SDMXUtilityData-methods.R +++ b/R/SDMXUtilityData-methods.R @@ -19,7 +19,7 @@ SDMXUtilityData <- function(xmlObj, namespaces){ #methods #======= - +#'@export as.data.frame.SDMXUtilityData <- function(x, row.names=NULL, optional=FALSE, labels = FALSE, ...){ return(as.data.frame.SDMXCompactData(x, labels)) diff --git a/R/readSDMX.R b/R/readSDMX.R index 5035f32..4b577f4 100644 --- a/R/readSDMX.R +++ b/R/readSDMX.R @@ -423,7 +423,7 @@ readSDMX <- function(file = NULL, isURL = TRUE, isRData = FALSE, #using helpers strategy (with a resource parameter) if(buildRequest && resource %in% c("data","dataflow")){ - if(resource == "data" && providerId %in% c("ESTAT", "ISTAT", "ISTAT_LEGACY", "WBG_WITS", "CD2030", "IMF_DATA")){ + if(resource == "data" && providerId %in% c("ESTAT", "ISTAT", "ISTAT_LEGACY", "WBG_WITS", "CD2030", "IMF_DATA", "OECD")){ log$INFO("Attempt to fetch DSD ref from dataflow description") flow <- readSDMX(providerId = providerId, providerKey = providerKey, resource = "dataflow", resourceId = flowRef, headers = headers, verbose = TRUE, logger = logger, diff --git a/R/rsdmx.R b/R/rsdmx.R index c323daa..b5b3bc6 100644 --- a/R/rsdmx.R +++ b/R/rsdmx.R @@ -1,7 +1,6 @@ #' @name rsdmx #' @aliases rsdmx-package #' @aliases rsdmx -#' @docType package #' #' @title Tools for Reading SDMX Data and Metadata #' @description @@ -10,7 +9,14 @@ #' through theStatistical Data and Metadata Exchange (SDMX) framework. The package #' currently focuses on the SDMX XML standard format (SDMX-ML). #' - an web-service interface to well-known SDMX data providers +#' +#' @import R6 +#' @import methods +#' @import XML +#' @import httr +#' @import plyr +#' @import utils #' #'@author Emmanuel Blondel \email{emmanuel.blondel1@@gmail.com} #' -NULL \ No newline at end of file +"_PACKAGE" \ No newline at end of file diff --git a/R/rsdmx_logger.R b/R/rsdmx_logger.R index 03f91fe..80e0512 100644 --- a/R/rsdmx_logger.R +++ b/R/rsdmx_logger.R @@ -4,7 +4,6 @@ #' @export #' @keywords logger #' @return Object of \code{\link{R6Class}} for modelling a simple logger -#' @format \code{\link{R6Class}} object. #' #' @section Abstract Methods: #' \describe{ diff --git a/README.md b/README.md index 7104292..27ae41c 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ Copyright (C) 2014 Emmanuel Blondel Please note that following a new submission to CRAN, or eventually a modification of CRAN policies, the package might be temporarily archived, and removed from CRAN. In case you notice that the package is not back in few time, please contact me. #### on R-Universe -``rsdmx`` is available on the R-Universe public cloud server. The package version corresponds to the ongoing revision (master branch in Github). See [https://opensdmx.r-universe.dev/ui/#package:rsdmx](https://opensdmx.r-universe.dev/ui/#package:rsdmx) +``rsdmx`` is available on the R-Universe public cloud server. The package version corresponds to the ongoing revision (master branch in Github). See [https://opensdmx.r-universe.dev/#package:rsdmx](https://opensdmx.r-universe.dev/#package:rsdmx) ## Quickstart @@ -238,7 +238,7 @@ sdmx <- readSDMX(providerId = "MYORG", providerKey = NULL resource = "data", flo For embedded service providers that require a user authentication/subscription key or token, it is possible to specify it in ``readSDMX`` with the ``providerKey`` argument. If provided, and that the embedded provider requires a specific key parameter, the latter will be appended -to the SDMX web-request. For example, it's the case for the new [UNESCO SDMX API](https://apiportal.uis.unesco.org/getting-started). +to the SDMX web-request. @@ -253,10 +253,10 @@ This section will introduce you on how to read SDMX *dataset* documents. #### Read _remote_ datasets -The following code snipet shows you how to read a dataset from a remote data source, taking as example the [OECD StatExtracts portal](https://stats.oecd.org): [https://stats.oecd.org/restsdmx/sdmx.ashx/GetData/MIG/TOT../OECD?startTime=2000&endTime=2011](https://stats.oecd.org/restsdmx/sdmx.ashx/GetData/MIG/TOT../OECD?startTime=2000&endTime=2011) +The following code snipet shows you how to read a dataset from a remote data source, taking as example the [OECD StatExtracts portal](https://data-explorer.oecd.org/): [https://sdmx.oecd.org/public/rest/data/DSD_PRICES@DF_PRICES_N_CP01/GRC......./all/?startPeriod=2020&endPeriod=2020](https://sdmx.oecd.org/public/rest/data/DSD_PRICES@DF_PRICES_N_CP01/GRC......./all/?startPeriod=2020&endPeriod=2020) ```{r, echo = FALSE} -myUrl <- "https://stats.oecd.org/restsdmx/sdmx.ashx/GetData/MIG/TOT../OECD?startTime=2000&endTime=2011" +myUrl <- "https://sdmx.oecd.org/public/rest/data/DSD_PRICES@DF_PRICES_N_CP01/GRC......./all/?startPeriod=2020&endPeriod=2020" dataset <- readSDMX(myUrl) stats <- as.data.frame(dataset) ``` @@ -273,8 +273,8 @@ you register in rsdmx. Let's see how it would look like for querying an ``OECD`` datasource: ```{r, message = FALSE} -sdmx <- readSDMX(providerId = "OECD", resource = "data", flowRef = "MIG", - key = list("TOT", NULL, NULL), start = 2010, end = 2011) +sdmx <- readSDMX(providerId = "OECD", resource = "data", flowRef = "DSD_PRICES@DF_PRICES_N_CP01", + key = list("GRC", NULL, NULL, NULL, NULL, NULL, NULL, NULL), start = 2020, end = 2020) df <- as.data.frame(sdmx) head(df) ``` @@ -289,9 +289,9 @@ to the previous request, and specify ``labels = TRUE`` when calling ``as.data.fr as follows: ```{r, message = FALSE} -sdmx <- readSDMX(providerId = "OECD", resource = "data", flowRef = "MIG", - key = list("TOT", NULL, NULL), start = 2010, end = 2011, - dsd = TRUE) +sdmx <- readSDMX(providerId = "OECD", resource = "data", flowRef = "DSD_PRICES@DF_PRICES_N_CP01", + key = list("GRC", NULL, NULL, NULL, NULL, NULL, NULL, NULL), start = 2020, end = 2020, + dsd = TRUE) df <- as.data.frame(sdmx, labels = TRUE) head(df) ``` @@ -302,11 +302,11 @@ to a dataset by using the function ``setDSD``. Let's try how it works: ```{r, message = FALSE} #data without DSD -sdmx.data <- readSDMX(providerId = "OECD", resource = "data", flowRef = "MIG", - key = list("TOT", NULL, NULL), start = 2010, end = 2011) +sdmx.data <- readSDMX(providerId = "OECD", resource = "data", flowRef = "DSD_PRICES@DF_PRICES_N_CP01", + key = list("GRC", NULL, NULL, NULL, NULL, NULL, NULL, NULL), start = 2020, end = 2020) #DSD -sdmx.dsd <- readSDMX(providerId = "OECD", resource = "datastructure", resourceId = "MIG") +sdmx.dsd <- readSDMX(providerId = "OECD", resource = "datastructure", resourceId = "DSD_PRICES") #associate data and dsd sdmx.data <- setDSD(sdmx.data, sdmx.dsd) @@ -338,23 +338,12 @@ This section will introduce you on how to read SDMX **metadata** complete ``data ``` -#### Data Structures - -This example illustrates how to read the complete list of data structures (or key families) from the [OECD StatExtracts portal](https://stats.oecd.org) - -```{r, echo = FALSE} -dsUrl <- "https://stats.oecd.org/restsdmx/sdmx.ashx/GetDataStructure/ALL" -ds <- readSDMX(dsUrl) -dsdf <- as.data.frame(ds) -head(dsdf) -``` - #### Data Structure Definition (DSD) -This example illustrates how to read a complete DSD using a [OECD StatExtracts portal](https://stats.oecd.org) data source. +This example illustrates how to read a complete DSD using a [OECD StatExtracts portal](https://data-explorer.oecd.org/) data source. ```{r, echo = FALSE} -dsdUrl <- "https://stats.oecd.org/restsdmx/sdmx.ashx/GetDataStructure/TABLE1" +dsdUrl <- "https://sdmx.oecd.org/public/rest/datastructure/all/DSD_PRICES/latest/?references=children" dsd <- readSDMX(dsdUrl) ``` @@ -364,7 +353,7 @@ dsd <- readSDMX(dsdUrl) #get codelists from DSD cls <- slot(dsd, "codelists") codelists <- sapply(slot(cls, "codelists"), function(x) slot(x, "id")) #get list of codelists -codelist <- as.data.frame(slot(dsd, "codelists"), codelistId = "CL_TABLE1_FLOWS") #get a codelist +codelist <- as.data.frame(slot(dsd, "codelists"), codelistId = "CL_TRANSFORMATION") #get a codelist ``` In a similar way, the ``concepts`` of the dataset can be extracted from the DSD and read as ``data.frame``. diff --git a/man/SDMXDotStatRequestBuilder.Rd b/man/SDMXDotStatRequestBuilder.Rd index bbd39a5..1ab8122 100644 --- a/man/SDMXDotStatRequestBuilder.Rd +++ b/man/SDMXDotStatRequestBuilder.Rd @@ -54,10 +54,6 @@ an authentication or subscription user key/token has to be provided to perform r \note{ Internal class - -dataflow' resource (path="GetKeyFamily/{resourceID}") -datastructure' resource (path="GetDataStructure/{resourceID}/{agencyID}") -data' resource (path="GetData/{flowRef}/{key}/{agencyId}") } \section{Warning}{ diff --git a/man/getNamespaces.Rd b/man/getNamespaces.Rd deleted file mode 100644 index 870f7bd..0000000 --- a/man/getNamespaces.Rd +++ /dev/null @@ -1,33 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/SDMX-methods.R -\docType{methods} -\name{getNamespaces} -\alias{getNamespaces} -\alias{getNamespaces,SDMX-method} -\title{getNamespaces} -\usage{ -getNamespaces(obj) - -\S4method{getNamespaces}{SDMX}(obj) -} -\arguments{ -\item{obj}{An object deriving from class "SDMX"} -} -\value{ -an object of class \code{data.frame} giving the id and uri for each - of the namespaces handled in the SDMX-ML document. -} -\description{ -Access the namespaces of the SDMX-ML object -} -\section{Methods (by class)}{ -\itemize{ -\item \code{getNamespaces(SDMX)}: Access the namespaces of the SDMX-ML object - -}} -\seealso{ -\link{SDMX-class} -} -\author{ -Emmanuel Blondel, \email{emmanuel.blondel1@gmail.com} -} diff --git a/man/getStructureType-methods.Rd b/man/getStructureType-methods.Rd deleted file mode 100644 index 44f448a..0000000 --- a/man/getStructureType-methods.Rd +++ /dev/null @@ -1,27 +0,0 @@ -\name{getStructureType-methods} -\docType{methods} -\alias{getStructureType,SDMXStructureType-method} -\alias{getStructureType} -\title{getStructureType} -\description{Access the subtype of SDMXStructureType object} - -\usage{ -getStructureType(obj) -} - -\arguments{ - \item{obj}{An object deriving from class "SDMXStructureType"} -} - -\section{Methods}{ -\describe{ - \item{obj}{An object deriving from class "SDMXStructureType"} -}} - -\value{an object of class "character"} - -\author{Emmanuel Blondel, \email{emmanuel.blondel1@gmail.com}} - -\keyword{methods} - -\seealso{\link{SDMXStructureType-class}} diff --git a/man/namespaces.SDMX.Rd b/man/namespaces.SDMX.Rd deleted file mode 100644 index c09a226..0000000 --- a/man/namespaces.SDMX.Rd +++ /dev/null @@ -1,24 +0,0 @@ -\name{namespaces.SDMX} -\Rdversion{1.1} -\alias{namespaces.SDMX} -\title{namespaces.SDMX} - -\description{function used to get the namespaces handled by an SDMX-ML object} - -\usage{ -namespaces.SDMX(xmlObj) -} - -\arguments{ -\item{xmlObj}{an object of class "XMLInternalDocument"} -} - -\value{an object of class "data.frame" giving the namespace(s) id and uri} - -\author{Emmanuel Blondel, \email{emmanuel.blondel1@gmail.com}} - -\section{Warning}{\code{namespaces.SDMX} is a function used internally to get the -namespaces of the SDMX-ML object through \link{getNamespaces}. This last function -is used an utility re-used in the different SDMX document parsers.} - -\seealso{\link{SDMXType-class} \link{getNamespaces}} \ No newline at end of file diff --git a/man/rsdmx.Rd b/man/rsdmx.Rd index 2f34cf7..6edbdfb 100644 --- a/man/rsdmx.Rd +++ b/man/rsdmx.Rd @@ -11,6 +11,15 @@ RSDMX is a package to parse/read SDMX documents in R. It provides: through theStatistical Data and Metadata Exchange (SDMX) framework. The package currently focuses on the SDMX XML standard format (SDMX-ML). - an web-service interface to well-known SDMX data providers +} +\seealso{ +Useful links: +\itemize{ + \item \url{https://github.com/opensdmx/rsdmx} + \item \url{https://sdmx.org} + \item Report bugs at \url{https://github.com/opensdmx/rsdmx/issues} +} + } \author{ Emmanuel Blondel \email{emmanuel.blondel1@gmail.com} diff --git a/man/rsdmxLogger.Rd b/man/rsdmxLogger.Rd index 18cbde2..00113b3 100644 --- a/man/rsdmxLogger.Rd +++ b/man/rsdmxLogger.Rd @@ -4,9 +4,6 @@ \name{rsdmxLogger} \alias{rsdmxLogger} \title{rsdmxLogger} -\format{ -\code{\link{R6Class}} object. -} \value{ Object of \code{\link{R6Class}} for modelling a simple logger } diff --git a/man/setDSD.Rd b/man/setDSD.Rd deleted file mode 100644 index b687179..0000000 --- a/man/setDSD.Rd +++ /dev/null @@ -1,34 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/SDMXData-methods.R -\docType{methods} -\name{setDSD} -\alias{setDSD} -\alias{setDSD,SDMXData-method} -\title{setDSD} -\usage{ -setDSD(obj, dsd) - -\S4method{setDSD}{SDMXData}(obj, dsd) -} -\arguments{ -\item{obj}{An object deriving from class "SDMXData"} - -\item{dsd}{An object of class "SDMXDataStructureDefinition"} -} -\value{ -the 'obj' object of class "SDMXData" enriched with the dsd -} -\description{ -set the 'dsd' slot of a \code{SDMXData} object -} -\section{Methods (by class)}{ -\itemize{ -\item \code{setDSD(SDMXData)}: set the 'dsd' slot of a \code{SDMXData} object - -}} -\seealso{ -\link{SDMXData-class} -} -\author{ -Emmanuel Blondel, \email{emmanuel.blondel1@gmail.com} -} diff --git a/man/setSDMXServiceProviders.Rd b/man/setSDMXServiceProviders.Rd index e4295b6..e3d5fb9 100644 --- a/man/setSDMXServiceProviders.Rd +++ b/man/setSDMXServiceProviders.Rd @@ -17,16 +17,6 @@ function used internally by \pkg{rsdmx}, when loading the package, \seealso{ \link{getSDMXServiceProviders} \link{addSDMXServiceProvider} \link{findSDMXServiceProvider} \link{readSDMX} - -dataflow' resource (path="dataset/{resourceId}/def.sdmx.xml") -datastructure' resource (path="dataset/{resourceID}.structure.sdmx.xml") -data' resource (path="dataset/{resourceID}.generic.sdmx.xml") -dataflow' resource (path="/") -datastructure' resource (path="/{resourceID}) -data' resource (path="getdata?dataflow={flowRef}&key={key}) -dataflow' resource (path="/") -datastructure' resource (path="/{resourceID}) -data' resource (path="getdata?dataflow={flowRef}&key={key}) } \author{ Emmanuel Blondel, \email{emmanuel.blondel1@gmail.com} diff --git a/vignettes/quickstart.Rmd b/vignettes/quickstart.Rmd index d41e7b7..3790152 100644 --- a/vignettes/quickstart.Rmd +++ b/vignettes/quickstart.Rmd @@ -49,7 +49,7 @@ remotes::install_github("opensdmx/rsdmx") To load rsdmx in R, do the following: -```{r,eval = FALSE,results="hide"} +```{r,eval = TRUE,results="hide"} library(rsdmx) ``` @@ -61,12 +61,12 @@ This section will introduce you on how to read SDMX *dataset* documents, either #### using the _raw_ approach (specifying the complete request URL) -The following code snipet shows you how to read a dataset from a remote data source, taking as example the [OECD StatExtracts portal](https://stats.oecd.org): [https://stats.oecd.org/restsdmx/sdmx.ashx/GetData/MIG/TOT../OECD?startTime=2000&endTime=2011](https://stats.oecd.org/restsdmx/sdmx.ashx/GetData/MIG/TOT../OECD?startTime=2000&endTime=2011) +The following code snipet shows you how to read a dataset from a remote data source, taking as example the [OECD StatExtracts portal](https://data-explorer.oecd.org/): [https://sdmx.oecd.org/public/rest/data/DSD_PRICES@DF_PRICES_N_CP01/GRC......./all/?startPeriod=2020&endPeriod=2020](https://sdmx.oecd.org/public/rest/data/DSD_PRICES@DF_PRICES_N_CP01/GRC......./all/?startPeriod=2020&endPeriod=2020) -```{r,eval = FALSE,results="hide"} -myUrl <- "https://stats.oecd.org/restsdmx/sdmx.ashx/GetData/MIG/TOT../OECD?startTime=2000&endTime=2011" +```{r, echo = FALSE} +myUrl <- "https://sdmx.oecd.org/public/rest/data/DSD_PRICES@DF_PRICES_N_CP01/GRC......./all/?startPeriod=2020&endPeriod=2020" dataset <- readSDMX(myUrl) -stats <- as.data.frame(dataset) +stats <- as.data.frame(dataset) ``` You can try it out with other datasources, such as from the [**EUROSTAT portal**](https://ec.europa.eu/eurostat): [https://ec.europa.eu/eurostat/api/dissemination/sdmx/2.1/data/NAMA_10_GDP/A.CP_MEUR.B1GQ.BE+LU](https://ec.europa.eu/eurostat/api/dissemination/sdmx/2.1/data/NAMA_10_GDP/A.CP_MEUR.B1GQ.BE+LU) @@ -86,9 +86,9 @@ Note it is also possible to add an SDMX service provider at runtime. For registe Let's see how it would look like for querying an ``OECD`` datasource: -```{r, eval = FALSE,message = FALSE,results="hide"} -sdmx <- readSDMX(providerId = "OECD", resource = "data", flowRef = "MIG", - key = list("TOT", NULL, NULL), start = 2010, end = 2011) +```{r, message = FALSE} +sdmx <- readSDMX(providerId = "OECD", resource = "data", flowRef = "DSD_PRICES@DF_PRICES_N_CP01", + key = list("GRC", NULL, NULL, NULL, NULL, NULL, NULL, NULL), start = 2020, end = 2020) df <- as.data.frame(sdmx) head(df) ``` @@ -102,10 +102,10 @@ To do so, you only need to append ``dsd = TRUE`` (default value is ``FALSE``), to the previous request, and specify ``labels = TRUE`` when calling ``as.data.frame``, as follows: -```{r, eval = FALSE,message = FALSE,results="hide"} -sdmx <- readSDMX(providerId = "OECD", resource = "data", flowRef = "MIG", - key = list("TOT", NULL, NULL), start = 2010, end = 2011, - dsd = TRUE) +```{r, message = FALSE} +sdmx <- readSDMX(providerId = "OECD", resource = "data", flowRef = "DSD_PRICES@DF_PRICES_N_CP01", + key = list("GRC", NULL, NULL, NULL, NULL, NULL, NULL, NULL), start = 2020, end = 2020, + dsd = TRUE) df <- as.data.frame(sdmx, labels = TRUE) head(df) ``` @@ -113,7 +113,7 @@ head(df) For embedded service providers that require a user authentication/subscription key or token, it is possible to specify it in ``readSDMX`` with the ``providerKey`` argument. If provided, and that the embedded provider requires a specific key parameter, the latter will be appended -to the SDMX web-request. For example, it's the case for the new [UNESCO SDMX API](https://apiportal.uis.unesco.org/getting-started). +to the SDMX web-request. Note that in case you are reading SDMX-ML documents with the native approach (with URLs), instead of the embedded providers, it is also possible to associate a DSD @@ -121,11 +121,11 @@ to a dataset by using the function ``setDSD``. Let's try how it works: ```{r, eval = FALSE,message = FALSE,results="hide"} #data without DSD -sdmx.data <- readSDMX(providerId = "OECD", resource = "data", flowRef = "MIG", - key = list("TOT", NULL, NULL), start = 2010, end = 2011) +sdmx.data <- readSDMX(providerId = "OECD", resource = "data", flowRef = "DSD_PRICES@DF_PRICES_N_CP01", + key = list("GRC", NULL, NULL, NULL, NULL, NULL, NULL, NULL), start = 2020, end = 2020) #DSD -sdmx.dsd <- readSDMX(providerId = "OECD", resource = "datastructure", resourceId = "MIG") +sdmx.dsd <- readSDMX(providerId = "OECD", resource = "datastructure", resourceId = "DSD_PRICES") #associate data and dsd sdmx.data <- setDSD(sdmx.data, sdmx.dsd) @@ -156,10 +156,10 @@ This section will introduce you on how to read SDMX **metadata** complete ``data ### Data Structure Definition (DSD) -This example illustrates how to read a complete DSD using a [OECD StatExtracts portal](https://stats.oecd.org) data source. +This example illustrates how to read a complete DSD using a [OECD StatExtracts portal](https://data-explorer.oecd.org/) data source. -```{r,eval = FALSE,results="hide"} -dsdUrl <- "https://stats.oecd.org/restsdmx/sdmx.ashx/GetDataStructure/TABLE1" +```{r, echo = FALSE} +dsdUrl <- "https://sdmx.oecd.org/public/rest/datastructure/all/DSD_PRICES/latest/?references=children" dsd <- readSDMX(dsdUrl) ```