ropensci / fingertipsR

R package to interact with Public Health England’s Fingertips data tool
https://docs.ropensci.org/fingertipsR
92 stars 18 forks source link

unsychronised data between fingertipsR and the PHOF fingertips site #97

Closed stevecrawshaw closed 3 years ago

stevecrawshaw commented 3 years ago

It looks like the data on fingertipsR is not in sync with that published on the website e.g.

has 2019 data

if I use the fingertipsR API, the latest year is 2018

library(tidyverse)
library(fingertipsR)
indid <- 30101
fingertips_data(IndicatorID = indid, AreaTypeID = 202) %>% 
    filter(AreaName %in% c("South West region", "England", "Bristol")) %>% 
    transmute(Area = AreaName, Year = as.integer(Timeperiod), Value) %>% 
   select(Year) %>% 
    filter(Year == max(Year))

please advise..

sebastian-fox commented 3 years ago

Hi @stevecrawshaw

Thanks for the message. You're right that the API shouldn't be out of sync with the website. When it is it is usually a question of AreaTypeID. This is the case for your query. See below:

library(fingertipsR)
library(dplyr)

indid <- 30101

aq <- fingertips_data(IndicatorID = indid, AreaTypeID = 202) %>% 
  filter(AreaName %in% c("South West region", "England", "Bristol")) %>% 
  transmute(Area = AreaName, Year = as.integer(Timeperiod), Value) %>% 
  select(Year) %>% 
  filter(Year == max(Year))

print(aq)

aq_pre_2019 <- fingertips_data(IndicatorID = indid, AreaTypeID = 102) %>% 
  filter(AreaName %in% c("South West region", "England", "Bristol")) %>% 
  transmute(Area = AreaName, Year = as.integer(Timeperiod), Value) %>% 
  select(Year) %>% 
  filter(Year == max(Year))

print(aq_pre_2019)

I can't answer why AreaTypeID = 202 doesn't go up to 2019. You'd need to contact the Fingertips team if you want that answer.

Does this make sense? If so, please could you close this issue. Thank you

stevecrawshaw commented 3 years ago

Thanks Sebastian for your quick reply, it looks like its something to do with timelines of boundary changes:

AreaTypeID AreaTypeName 1 102 Upper tier local authorities (pre 4/19) 2 202 Upper tier local authorities (4/19 - 3/20)

as you say, the data is timely for the AreaTypeID 102. Will close now, thanks.