The fingertipsR package

R tools to access open public health data via Fingertips

Find profiles

Fingertips is a large repository of public health indicators managed by Public Health England. It is organised into:

  • Profiles
  • Domains
  • Indicators

each of which is identified by unique IDs.

The fingertipsR package has functions which interact with the Fingertips API to find profile, domain and indicator IDs, find metadata and download data. It can be installed in R from https://github.com/PublicHealthEngland/fingertipsR. An example of use can be seen here.

Finding out what’s in Fingertips

The profiles() function can download all the profiles, or search for specific profiles with an appopriate search string. The overall structure of Fingertips can be viewed below.

library(fingertipsR)
options(scipen = 100)
profiles <- profiles()
head(profiles) %>%
  knitr::kable()
ProfileID ProfileName DomainID DomainName
8 Adult Social Care 1000101 Enhancing quality of life for people
8 Adult Social Care 1000102 Delaying and reducing the need for care and support
8 Adult Social Care 1000103 Ensuring a positive experience of care and support
8 Adult Social Care 1000104 Safeguarding vulnerable adults
8 Adult Social Care 1000105 People with care and support needs
8 Adult Social Care 1938132733 Better Care Fund
library(collapsibleTree)
library(RColorBrewer)
fingertips <- indicators()

collapsibleTree(linkLength = 200, fingertips, hierarchy = c("ProfileName", "DomainName", "IndicatorName"), height = 1000, width = 1200, tooltip = TRUE, fillByLevel = TRUE)

Find mental health profiles

profile_mh <- profiles() %>% filter(str_detect(ProfileName, "[Mm]ental"))

profile_mh %>%
  select(ProfileID, ProfileName) %>%
  distinct() %>%
  knitr::kable()
ProfileID ProfileName
36 Mental Health Dementia and Neurology
40 Common Mental Health Disorders
41 Severe Mental Illness
72 Children’s and Young People’s Mental Health and Wellbeing
79 Co-occurring substance misuse and mental health issues
98 Mental Health JSNA

Find indicators

The indicators() function identifies indicators and indicatorIDs for named profiles, domains or profile or domain IDs. Running indicators() with no parameters returns a complete dataframe of all the indicators in Fingertips.

## find indicators in profile 41 - severe mental illness

mh_ind <- indicators(ProfileID = 41)

mh_ind %>%
  select(IndicatorID, IndicatorName) %>%
  head() %>%
  knitr::kable()
IndicatorID IndicatorName
90371 New cases of psychosis: estimated incidence rate of psychosis per 100,000 population aged 16-64
90372 People on Care Programme Approach (CPA): rate per 100,000 population aged 18+ (end of quarter snapshot)
90404 Estimated % of population aged 16+ with a psychotic disorder
90409 Mental health admissions to hospital: rate (quarterly) per 100,000 population aged 18+
90413 People subject to Mental Health Act: rate per 100,000 population aged 18+ (end of quarter snapshot)
90420 CPA adults in employment: % of people aged 18-69 on CPA in employment (end of quarter snapshot)

Getting data

The workhorse of the fingertipsR package is the fingertips_data() function. This downloads the data. It can be be used to download data for specified indicators, profiles, areas or combinations. Unless specified with an AreaTypeID code, it downloads data for Upper Tier Local Authorities (AreaTypeID = 102) if available. Use the area_types() function to find available areas and relevant AreaTypeID codes. This also shows relevant geographical hierarchies.

areas <- area_types()
areas %>%
  select(AreaID, AreaName) %>%
  distinct() %>%
  knitr::kable()
AreaID AreaName
2 Primary Care Trust
3 Middle Super Output Area
6 Government Office Region
7 General Practice
8 Ward
19 Clinical Commissioning Group
41 Ambulance Trust
46 Sub-region (former Local area teams)
101 Local authority districts and Unitary Authorities
102 Counties and Unitary Authorities
103 PHEC 2013 only plus PHEC unchanged
104 PHEC 2015 new plus PHEC 2013 unchanged
112 Strategic Clinical Network
118 Acute Trusts (incl.combined MH+Acute)
119 Mental Health Trusts (incl.combined MH+Acute)
120 Sustainability and Transformation Footprints
122 Bowel Cancer Screening Centres
125 Maternity Services
126 Combined authorities
## get mental health data for CCGs

mh_data <- fingertips_data(IndicatorID = 90409, AreaTypeID = 19)

mh_data %>%
  slice(30) %>%
  t() %>%
  data.frame() %>%
  knitr::kable(align = "left")
.
IndicatorID 90409
IndicatorName Mental health admissions to hospital: rate (quarterly) per 100,000 population aged 18+
ParentCode
ParentName
AreaCode E92000001
AreaName England
AreaType Country
Sex Persons
Age 18+ yrs
CategoryType CCG deprivation deciles in England (IMD2010)
Category Least deprived decile
Timeperiod 2013/14 Q1
Value 41.80643
LowerCIlimit NA
UpperCIlimit NA
Count 1614
Denominator 3860650
Valuenote Aggregated from all known lower geography values
RecentTrend
ComparedtoEnglandvalueorpercentiles Not compared
Comparedtosubnationalparentvalueorpercentiles Not compared

If data is available the package will download data categorised by deprivation decile, recent trend categories (improving, no change, worsening), and benchmark comparison (better, no different, worse).

The data is available as a tidy data frame and can be further plotted, analysed and mapped in the usual way. One issue to be aware of is that character variables are downloaded as factors (categorical variables). They can easily be converted using the mutate_if function from the dplyr package.

library(govstyle)

mh_data <- mh_data %>%
  mutate_if(is.factor, as.character)


mh_data %>%
  filter(AreaName == "England" & CategoryType == "") %>%
  ggplot(aes(Timeperiod, Value)) +
  geom_point() +
  geom_line(aes(group = 1)) +
  labs(title = str_wrap(mh_data$IndicatorName, 60)) +
  theme_gov()

g <- mh_data %>%
  filter(AreaName == "England" & CategoryType == "CCG deprivation deciles in England (IMD2010)") %>%
  ggplot(aes(Timeperiod, Value), colour = Category) +
  geom_point() +
  geom_line(aes(colour = Category, group = Category)) +
  labs(title = str_wrap(mh_data$IndicatorName, 60)) +
  theme_gov()

  
  
  g + geom_text(data = mh_data %>% filter( Timeperiod == "2014/15 Q2" & CategoryType == "CCG deprivation deciles in England (IMD2010)" ), 
            size  = 2, 
            aes(
    label = str_wrap(Category,30),
    hjust = 0,
    vjust = 0
  ))

Other functions

Indicator metadata

We can use the indicator_metadata() function to extract all the metadata for each variable.

ind_meta <- indicator_metadata(IndicatorID = 90409)

ind_meta %>% t() %>%
  data.frame() %>%
  knitr::kable()
.
Indicator.ID 90409
Indicator Mental health admissions to hospital: rate (quarterly) per 100,000 population aged 18+
Indicator.full.name Mental health admissions to hospital: rate (quarterly) per 100,000 population aged 18+
Definition Number of admissons to secondary mental health services during the quarter expressed as a rate per 100,000 aged 18+
Rationale NA
Policy NA
Data.source Health & Social Care Information Centre
Indicator.production NA
Indicator.source NA
Methodology Numerator/denominator multiplied by 100,000
Standard.population.values NA
Confidence.interval.details NA
Source.of.numerator Monthly Mental Health Minimum Data Set (MHMDS) Reports, Health & Social Care Information Centre http://www.hscic.gov.uk/mhmdsmonthly (field reference number mm26)
Definition.of.numerator Number of people admitted to secondary mental health services (sum of 3 months in the quarter)
Source.of.denominator Mid-year population estimates (ONS).The latest published 2014/15 indicators use mid-year estimates for 2013 http://www.ons.gov.uk/ons/publications/re-reference-tables.html?edition=tcm%3A77-367629
Definition.of.denominator Population aged 18+
Disclosure.control NA
Caveats December 2015: Indicators from Q3 2014/15 affected by transition from MHMDS to MHLDDS:
In September 2014, the Mental Health Minimum Dataset (MHMDS) was superseded by the Mental Health and Learning Disabilities Dataset (MHLDDS) to reflect the inclusion of people in contact with learning disability services. Many people who have a learning disability use mental health services and people in learning disability services may have a mental health problem. This means that activity included in the new MHLDDS dataset cannot be distinctly divided into mental health or learning disability spells of care – a single spell of care may include inputs from one or both types of service.
In this Severe Mental Illness Fingertips tool:
- ‘End of quarter snapshot’ in dicators from Q3 2014/15 based on the MHLDDS exclude people who, at the end of each quarter, were solely in contact with learning disability services, using data produced by the HSCIC by arrangement.
- ‘Sum of quarter’ indicators from Q3 2014/15 that would be based on the MHLDDS have not been able to be updated. It is hoped to update these indicators in a way which focuses on mental health services activity using the Mental Health Services Dataset (MHSDS), for which data collection begins in January 2016.March 2015: Indicators for Q2 2014/15 affected by transition from MHMDS to MHLDDS:
- ‘Snapshot’ indicators for Q2 2014/15 show end of August 2014 position
- ‘Sum of quarter’ indicators for Q2 2014/15 based on the two-month July 2014 and August 2014 total pro-rated up to represent three months
From September 2014 the monthl y source data reports used to compute this indicator were extended in scope to additionally cover Learning Disabilities services. Therefore, data are not comparable between August and September 2014 for some measures and so the September data cannot be used. As an interim measure, the end of August position is used for Q2 snapshot measures and the two-month July and August total is used for indicators based on a sum of the quarter. These values may be revised in future.This indicator is based on the monthly MHMDS file. Local knowledge may be required to assess the completeness and accuracy of the data. Only a small number of independent sector providers are making submissions so the picture is incomplete. Submissions often include duplicate or overlapping entries which affect the accuracy of the statistics.
See data quality statement: h ttp://www.hscic.gov.uk/media/14816/Monthly-MHMDS-Reports—2014-15-Background-data-quality-report/pdf/Monthly_MHMDS_Reports_-_2014-15__Background_data_quality_report.pdf
Some of these statistics are p resently experimental in nature and are likely to be subject to further refinement before the final constructions are confirmed - reference should be made to the supporting notes and commentary when using these statistics
Some methodological changes we re implemented between 2013/14 and 2014/15, These should be considered when viewing trend data. Details of changes are here: http://www.hscic.gov.uk/media/14272/Monthly-MHMDS-Reports---2014-15-Methodological-change/pdf/MHMDS_Reports_-_Methodological_Change.pdf
Copyright NA
Data.re.use NA
Links Further indicators relating to severe mental illness and mental health crisis care can be found on:Severe Mental Illness
This tool presents collated ri sk, prevalence, early intervention, assessment and treatment, outcomes and service costs data relating to people with psychosis and other forms of severe mental illness.Crisis Care Profile
This profile brings together n ationally available data on mental health crisis care, including metrics for; prevalence, risk factors, prevention, access to support, access to urgent care, and quality of treatment.
Indicator.number NA
Notes NA
Frequency NA
Rounding NA
Data.quality 2
Indicator.Content NA
Unit per 100,000
Value.type Crude rate
Year.type Financial