Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error converting SDMX objects without time series structure to data.frame #133

Closed
laakmann opened this issue Oct 1, 2017 · 3 comments
Closed
Assignees
Milestone

Comments

@laakmann
Copy link

laakmann commented Oct 1, 2017

Some useful datasets on OECD.stats are available without the usual time series structure, i.e., one cannot filter the dataset by time and the data are not returned with time attributes. For instance, the Better Life Index data can be obtained for several recent years but this requires querying a different dataset for each year (not exactly ideal, but....).

I am able to successfully query the data and the XML contents appear to be consistent with what I'd expect to see (values, structure, etc), however when I attempt to convert the object into a data frame it errors out.

basic example with 2015 BLI dataset

# short simple query
obj = rsdmx::readSDMX('http://stats.oecd.org/restsdmx/sdmx.ashx/GetData/BLI2015/AUS+AUT+BEL.IW_HADI+IW_HNFW.L.TOT/all')

sdf = as.data.frame(obj)
### Error Message here:
# Error in getNodeSet(obsXML, paste("//ns:", timeElement, sep = ""), namespaces = ns)[[1]] : 
#  subscript out of bounds


### Traceback
# 11: parseObs(x)
# 10: FUN(X[[i]], ...)
# 9: lapply(obssXML, function(x) parseObs(x))
# 8: do.call("rbind.fill", lapply(obssXML, function(x) parseObs(x)))
# 7: parseSerie(x)
# 6: FUN(X[[i]], ...)
# 5: lapply(seriesXML, function(x) {
#   serie <- parseSerie(x)
# })
# 4: do.call("rbind.fill", lapply(seriesXML, function(x) {
#   serie <- parseSerie(x)
# }))
# 3: as.data.frame.SDMXGenericData(x, labels = labels)
# 2: as.data.frame.SDMXMessageGroup(obj)
# 1: as.data.frame(obj)

It is apparent this is occurring due to the missing time series attribute, however I need to spend more time studying the code, documentation, etc to fix it properly myself (i.e., without breaking other stuff). Perhaps I can take a crack at this later.

Thank you for the useful package!
Pete

@eblondel
Copy link
Member

eblondel commented Oct 1, 2017

@laakmann thanks for this info. I've pushed a quick fix, as it didn't require a lot of work. Can you please re-test? Thanks

@laakmann
Copy link
Author

laakmann commented Oct 1, 2017

Works for me. Thanks!

@eblondel
Copy link
Member

eblondel commented Oct 2, 2017

Great! @laakmann If rsdmx is useful for you, do not forget to start it! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants