readSDMX | R Documentation |
readSDMX
is the main function to use to read SDMX data
readSDMX(file = NULL, isURL = TRUE, isRData = FALSE,
provider = NULL, providerId = NULL, providerKey = NULL,
agencyId = NULL, resource = NULL, resourceId = NULL, version = NULL,
flowRef = NULL, key = NULL, key.mode = "R", start = NULL, end = NULL, dsd = FALSE,
headers = list(), validate = FALSE,
verbose = !is.null(logger), logger = "INFO", ...)
file |
path to SDMX-ML document that needs to be parsed |
isURL |
a value of class "logical" either the path is an url, and data
has to be downloaded from a SDMXweb-repository. Default value is TRUE.
Ignored in case |
isRData |
a value of class "logical" either the path is local RData file
handling an object of class "SDMX", previously saved with |
provider |
an object of class "SDMXServiceProvider". If specified,
|
providerId |
an object of class "character" representing a provider id.
It has to be match a default provider as listed in |
providerKey |
an object of class "character" giving a key to authenticate for the given provider endpoint. Some providers may require an authentication or subscription key to perform SDMX requests. |
agencyId |
an object of class "character representing an agency id, for which data should be requested (from a particular service provider) |
resource |
an object of class "character" giving the SDMX service request resource to query e.g. "data". Recognized if a valid provider or provide id has been specified as argument. |
resourceId |
an object of class "character" giving a SDMX service resource Id, e.g. the id of a data structure |
version |
an object of class "character" giving a SDMX resource version, e.g. the version of a dataflow. |
flowRef |
an object of class "character" giving the SDMX flow ref id. Recognized if valid provider or provide id has been specified as argument. |
key |
an object of class "character" or "list" giving the SDMX data key/filter
to apply. Recognized if a valid provider or provide id has been specified as argument.
If |
key.mode |
an object of class "character" indicating if the |
start |
an object of class "integer" or "character" giving the SDMX start time to apply. Recognized if a valid provider or provide id has been specified as argument. |
end |
an object of class "integer" or "character" giving the SDMX end time to apply. Recognized if a valid provider or provide id has been specified as argument. |
dsd |
an Object of class "logical" if an attempt to inherit the DSD should be performed.
Active only if |
headers |
an object of class "list" that contains any additional headers for the request. |
validate |
an object of class "logical" indicating if a validation check has to be performed on the SDMX-ML document to check its SDMX compliance when reading it. Default is FALSE. |
verbose |
an Object of class "logical" that indicates if rsdmx logs should
appear to user. Default is set to |
logger |
reports if a logger has to be used to print log messages. Default is |
... |
(any other parameter to pass to httr::GET request) |
an object of class "SDMX"
Emmanuel Blondel, emmanuel.blondel1@gmail.com
# SDMX datasets
#--------------
## Not run:
# Not run
# (local dataset examples)
#with SDMX 2.0
tmp <- system.file("extdata","Example_Eurostat_2.0.xml", package="rsdmx")
sdmx <- readSDMX(tmp, isURL = FALSE)
stats <- as.data.frame(sdmx)
head(stats)
#with SDMX 2.1
tmpnew <- system.file("extdata","Example_Eurostat_2.1.xml", package="rsdmx")
sdmx <- readSDMX(tmpnew, isURL = FALSE)
stats <- as.data.frame(sdmx)
head(stats)
## End(**Not run**)
## End(Not run)
## Not run:
# Not run by 'R CMD check'
# (reliable remote datasource but with possible occasional unavailability)
#examples using embedded providers
sdmx <- readSDMX(providerId = "OECD", resource = "data", flowRef = "MIG",
key = list("TOT", NULL, NULL), start = 2011, end = 2011)
stats <- as.data.frame(sdmx)
head(stats)
#examples using 'file' argument
#using url (Eurostat REST SDMX 2.1)
url <- paste("http://ec.europa.eu/eurostat/SDMX/diss-web/rest/data/",
"cdh_e_fos/all/?startperiod=2000&endPeriod=2010",
sep = "")
sdmx <- readSDMX(url)
stats <- as.data.frame(sdmx)
head(stats)
## End(**Not run**)
## End(Not run)
# SDMX DataStructureDefinition (DSD)
#-----------------------------------
## Not run:
# Not run by 'R CMD check'
# (reliable remote datasource but with possible occasional unavailability)
#using embedded providers
dsd <- readSDMX(providerId = "OECD", resource = "datastructure",
resourceId = "WATER_ABSTRACT")
#get codelists from DSD
cls <- slot(dsd, "codelists")
codelists <- sapply(slot(cls,"codelists"), slot, "id") #get list of codelists
#get a codelist
codelist <- as.data.frame(cls, codelistId = "CL_WATER_ABSTRACT_SOURCE")
#get concepts from DSD
concepts <- as.data.frame(slot(dsd, "concepts"))
## End(**Not run**)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.