I'm trying to import data from Estonian national database through r into powerbi, but sometimes the data gives me an error which i don't know how to resolve.
I have tried using different data from the same database and with some it works fine, but others throw an error.
I have this code:
library(stringr)
library('rsdmx')
data = readSDMX('http://andmebaas.stat.ee/restsdmx/sdmx.ashx/GetData/LET171/1+2+3+4+5+6+7+8+9+10+11+12+13+14.1+2+3/all?startTime=2010&endTime=2016')
DF = as.data.frame(data)
dsd = readSDMX("http://andmebaas.stat.ee/restsdmx/sdmx.ashx/GetDataStructure/LET171")
cls=slot(dsd, "codelists")
codelists <- sapply(slot(cls, "codelists"), function(x) slot(x, "id"))
for(i in codelists){
kood <- str_sub(i, start= 10)
if(kood!="OBS_STATUS"){
assign(kood, as.data.frame(slot(dsd, "codelists"), codelistId = i))
}
}
It works fine with some data, for example using these links
dsd http://andmebaas.stat.ee/restsdmx/sdmx.ashx/GetDataStructure/RV021
The code is supposed to import the data into powerbi and create tables with data and identifiers, but with the links currently in the code it throws the following error
Error in colSums(is.na(codes)) :
'x' must be an array of at least two dimensions
In addition: Warning message:
In is.na(codes) : is.na() applied to non-(list or vector) of type 'NULL'