https://github.com/edwindj/sdmxdata
R package based on SDMX REST v2.1
https://github.com/edwindj/sdmxdata
Last synced: 11 months ago
JSON representation
R package based on SDMX REST v2.1
- Host: GitHub
- URL: https://github.com/edwindj/sdmxdata
- Owner: edwindj
- License: other
- Created: 2024-12-06T10:06:35.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-26T13:13:00.000Z (12 months ago)
- Last Synced: 2025-06-26T13:43:19.072Z (12 months ago)
- Language: R
- Homepage: https://edwindj.github.io/sdmxdata/
- Size: 1.84 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- License: LICENSE
Awesome Lists containing this project
README
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# sdmxdata
[](https://CRAN.R-project.org/package=sdmxdata)
[](https://github.com/edwindj/sdmxdata/actions/workflows/R-CMD-check.yaml)
[](https://lifecycle.r-lib.org/articles/stages.html#experimental)
## Introduction
_Work in progress, not to be used for production work_
Why `sdmxdata`? The package is designed to provide a simple interface to
retrieve and select data from open statistical data providers that support the SDMX v2.1 REST API.
It focusses on:
- retrieving a list of dataflows: `list_dataflows`, for getting an overview of the
available tables (aka dataflows) at a data provider, including their descriptions.
- retrieving the structure of a dataflow: `get_dataflow_structure`, for getting
detailed information on the structure and metadata of a dataflow.
- retrieving data: `get_data` and `get_observations`
for selecting and retrieving data from a dataflow. Both functions allow for
easy filtering on the server on dimensions, reporting periods, and other metadata.
- retrieving a list of agencies and subagencies: `list_agencies`, for getting an overview of the
agencies.
It does not implement a full fledged SDMX metadata model or data model. For that, you can use [`rsdmx`](https://CRAN.R-project.org/package=rsdmx).
## Installation
You can install the development version of sdmxdata from [GitHub](https://github.com/) with:
``` r
# install.packages("pak")
pak::pak("edwindj/sdmxdata")
```
## Example
```{r setup}
library(sdmxdata)
```
To retrieve a list of tables:
```{r}
CBSbeta <- sdmxdata::get_endpoint("NL1")
dfs <- CBSbeta |> list_dataflows()
dfs[,1:5] |>
head()
```
```{r}
OECD <- sdmxdata::get_endpoint("OECD")
dfs_oecd <- OECD |> list_dataflows()
dfs_oecd[,1:5] |>
head()
```
To retrieve a dataflow structure:
```{r}
dataflow_ref <- dfs$ref[4]
print(dataflow_ref)
dsd <- CBSbeta |> get_dataflow_structure(ref = dataflow_ref)
dsd
```
To retrieve data use `get_data`
```{r}
data <- CBSbeta |> get_data(agencyID=dsd$agencyID, id = dsd$id, pivot="Topics")
head(data)
```
Or get the underlying observations with `get_observations`
```{r}
obs <- CBSbeta |> get_observations(id="DF_37230ned", agencyID="NL1.CNVT")
```
```{r}
head(obs)
```
To retrieve a list of agencies or subagencies:
```{r}
agencies <- CBSbeta |> list_agencies()
head(agencies)
```
Use a URL to retrieve data:
```{r}
url <- "https://sdmx.oecd.org/public/rest/data/OECD.TAD.ARP,DSD_FISH_PROD@DF_FISH_AQUA,1.0/.A.._T.T?startPeriod=2010&dimensionAtObservation=AllDimensions"
obs <- get_observations_from_url(url)
head(obs)
```
Or return just the `sdmxdata::get_observations` command that would be used to retrieve the data:
```{r}
query <- get_observations_from_url(url, return_query = TRUE)
query
```