Edit this page

< back to recipes

Public Health England provide a wealth of data relating to health and wellbeing on the Fingertips website. The fingertipsR package allows you to extract the data behind the Fingertips website and recreate its visualisations using the companion fingertipscharts package. In this recipe we’ll compare the percentage of 5 year olds who’ve received two doses of the MMR vaccine in a local authority with England over time.

Ingredients

Instructions

  1. Load the necessary R packages.
library(tidyverse); library(fingertipsR) ; library(fingertipscharts)
  1. Run the select_indicators() function from the fingertipsR package. Enter your search terms into the popup browser window (e.g. “MMR vaccination”) and find the corresponding IndicatorID in the table. Now select the row and click ‘Done’. Close the browser and return to your R session. The IndicatorID, in this case 30311, will be stored in the object called ‘indicator’.
indicator <- select_indicators()
  1. Now let’s have a look at the metadata for that indicator to double check it is the one we want.
indicator_metadata(IndicatorID = indicator) %>% View()
  1. Next we need to pass the IndicatorID to the fingertips_data() function to retrieve the data from the Fingertips API.
df <- fingertips_data(IndicatorID = indicator)
  1. We then create a string object with the name of your local authority, e.g. Salford.
la <- "Salford"
  1. Finally, we plot the indicator alongside England as a comparator in a time series chart.
trends(df,
       timeperiod = Timeperiod,
       value = Value,
       area = AreaName,
       comparator = "England",
       area_name = la,
       fill = ComparedtoEnglandvalueorpercentiles,
       lowerci = LowerCI95.0limit,
       upperci = UpperCI95.0limit,
       title = paste0("Children in ", la, " receiving two doses of MMR by age 5"),
       subtitle = "Source: NHS Digital",
       xlab = "Year",
       ylab = "Percent",
       point_size = 3)


Notes

A helpful guide to the other visualisations available can be found in the fingertipscharts package vignette.