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

Data available through the fingertips website are not available through the fingertips r library #90

Closed arxan11 closed 4 years ago

arxan11 commented 4 years ago

Hi. I am having trouble acquiring data through fingertips r that are available through the fingertips website. Below is a screenshot of an example where you have the "% reporting learning disability" metric at CCG and gp practice level for a specific area:

finger_web_pic

Let's try and get the same data using the fingertips package:

library(fingertipsR)
library(dplyr)
#get a list of indicators
inds <- indicators_unique()

#find the indicator of interest & extract data for all areas & area types
see<-inds %>% filter(grepl("reporting learning disability", IndicatorName))
df<-fingertips_data(IndicatorID = see$IndicatorID, AreaTypeID = "All")%>%rename_all(tolower)

# check if data for the 1st from the top GP practice and the 5th from the top exist
"Y00058" %in% df$areacode
"J83063" %in% df$areacode

The outputs are TRUE and FALSE. Meaning data for Taw Hill Medical Practice are not available. This is the case for other GP practices within this area and also applies to other areas. Any suggestions?

sebastian-fox commented 4 years ago

Hi @arxan11 - thanks for reporting this. It looks like a bug with AreaTypeID = "All". I need to investigate it - it is a fairly new feature.

In the meantime, here is a robust workflow that will work:

library(fingertipsR)
library(dplyr)
#get a list of indicators
inds <- indicators_unique()

#find the indicator of interest & extract data for all areas & area types
see <- inds %>% 
  filter(grepl("reporting learning disability", IndicatorName))

ind_ats <- indicator_areatypes(see$IndicatorID) %>%
  left_join(area_types(), by = "AreaTypeID") %>%
  select(IndicatorID:AreaTypeName) %>%
  unique()

View(ind_ats) # see the table
# You want AreaTypeID == 7

df <- fingertips_data(IndicatorID = see$IndicatorID, AreaTypeID = 7) %>%
  rename_all(tolower)

# check if data for the 1st from the top GP practice and the 5th from the top exist
"Y00058" %in% df$areacode
"J83063" %in% df$areacode
sebastian-fox commented 4 years ago

Hi @arxan11 - I've updated the package to fix this bug. I'm going to push it to CRAN any day now. If you're happy to wait, you should be able to install it sometime next week using install.packages("fingertipsR") - otherwise, you can get the update now using:

if (!require(remotes)) install.packages("remotes")
remotes::install_github("rOpenSci/fingertipsR")

If you're happy with the fix, please could you close the issue. Thanks again

arxan11 commented 4 years ago

Thanks @sebastian-fox