Tuesday, 2 May 2017

Reading online SDMX data from R

Hi all,

After writing http://open-bi.blogspot.ch/2014/12/easy-query-to-sdmx-data.html some time ago (long time ...), I recently had to query online SDMX data from R.

Nothing more easier than playing with RSDMX package.

Just install this package : install.packages("rsdmx")
Then just play with it.

Here is a short exemple with a query to one ECB SDMX datasource.
 # Install and load the package  

 # First, set a proxy if you are behind corporate walls  

 # Then store your custom url, the one having the dataset you need  
 myUrl <- "http://stats.oecd.org/restsdmx/sdmx.ashx/GetData/MIG/TOT../OECD?startTime=2000&endTime=2011"  

 # Read and parse the data  
 dataset <- readSDMX(myUrl)  

 #Print the data. Tadam, your dataset is in a dataframe !   
 stats <- as.data.frame(dataset)   

 # Now, do intelligent stuff ...  

Now, the data.
Really easy and time saving.

No comments: