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

Errors when using ONS codes for some geographic areas #24

Open
cassier-barton opened this issue Apr 1, 2021 · 2 comments
Open

Errors when using ONS codes for some geographic areas #24

cassier-barton opened this issue Apr 1, 2021 · 2 comments

Comments

@cassier-barton
Copy link

There seems to be an issue with nomisr not returning data for certain types of geographic area.

I've been using ONS 9-digit codes to specify 'geography' within the nomis_get_data function (e.g. E92000001 for England) and this normally works great. But for certain geographic areas, it returns an error message.

For example, using the 9-digit code for the Abberton built-up area...

nomis_get_data(id = "NM_2010_1", geography = "E34003718", date = "latest")

... results in the following error message:

Error in if (as.numeric(first_df$RECORD_COUNT)[1] >= max_length) { :
missing value where TRUE/FALSE needed
In addition: Warning message:
Unknown or uninitialised column: RECORD_COUNT.

As far as I can tell this happens for all built-up areas, built-up area subdivisions, wards (post-2011), 'major towns and cities', CCGs and local health boards. I've been looking at this mostly using Nomis' small area based population estimates, but it looks like the the same issue applies with census tables as well.

Thanks for developing nomisr - it's extremely useful.

@evanodell
Copy link
Collaborator

Have you looked to see what geographies are available for that given dataset? I.e. using: nomis_get_metadata(id = "NM_2010_1", "GEOGRAPHY". Nomis uses its own geography codes in some datasets, you should check to see what they use and how they are classified first.

@cassier-barton
Copy link
Author

All of those geographies are available for that dataset - they show up when using nomis_get_metadata and when querying through the interface at nomisweb.co.uk.

I can successfully get data for these geographic areas manually using Nomis' web interface, and by using nomis_get_data when I specify geographies using Nomis' IDs. It's just using the 9-digit ONS codes that doesn't work for some reason.

I can't find a visible difference between areas that do work with 9-digit codes and those that don't (though I'm not sure where to look). For example...

9-digit codes do work for MSOAs. I can call up a list using nomis_get_metadata(id = "NM_2010_1", "GEOGRAPHY", type = "type297") and then get data for any given MSOA like this: nomis_get_data(id = "NM_2010_1", geography = "1245710779", date = "latest") Or like this: nomis_get_data(id = "NM_2010_1", geography = "E02006534", date = "latest")

Wards (2019) are one example that don't work with 9-digit codes. I can still call up a list - nomis_get_metadata(id = "NM_2010_1", "GEOGRAPHY", type = "type395") and get data using Nomis IDs - nomis_get_data(id = "NM_2010_1", geography = "1656752916", date = "latest"). But giving a 9-digit ONS code in the geography field results in an error.

As far as I can tell, the data tables for MSOAs and 2019 Wards are the same structure when retrieved using nomis_get_data, and both have a GEOGRAPHY_CODE column containing the relevant 9-digit codes. Presumably there is something different about how Nomis encodes data for these two geography types, but I can't figure out what.

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

No branches or pull requests

2 participants