ropensci / nomisr

Access UK official statistics from the Nomis database through R.
https://docs.ropensci.org/nomisr
Other
44 stars 12 forks source link

Data appears to be missing for certain indicators using nomisr but available to download through nomis web - is there a reason for this? #18

Closed ninarobery closed 4 years ago

ninarobery commented 4 years ago

For example the numerators are missing for main industrial sectors using following code:

library(dplyr) library(nomisr) aps_vars <- nomis_get_metadata("NM_17_5", concept = "variable")

Define geography:

GM_geos <- c(1946157081, 1946157082, 1946157083, 1946157084, 1946157085, 1946157086, 1946157087, 1946157088, 1946157089, 1946157090, 1853882369, 2013265922, 2092957699)

Main industrial sectors

industry_vars <- aps_vars %>% mutate(industry = if_else(id == 226, 1, if_else(id == 227, 1, if_else(id == 228, 1, if_else(id == 229, 1, if_else(id == 230, 1, if_else(id == 231, 1, if_else(id == 232, 1, if_else(id == 233, 1, if_else(id == 234, 1, if_else(id == 235, 1,0 ))))))))))) %>% filter(industry == 1) %>% select(id) %>% pull(id)

industry_data <- nomis_get_data(id = "NM_17_5", date = "previousMINUS2", geography = GM_geos, variable = industry_vars, measures = c(20599, 21001, 21002)) %>% select(DATE_NAME, GEOGRAPHY, GEOGRAPHY_NAME, GEOGRAPHY_CODE, VARIABLE_NAME, MEASURES_NAME, OBS_VALUE)

This code only brings back denominator data

evanodell commented 4 years ago

Try

industry_data2 <- nomis_get_data(id = "NM_17_5",date = "previousMINUS2",  
geography = GM_geos, variable = c(1339:1348), measures = c(20599, 21001, 21002))

Your query uses the old SIC 92/03, while the web query defaults to SIC 2007 classification, which is variables 1339 to 1348.

Let me know if that works or not.

ninarobery commented 4 years ago

That has now worked - many thanks.