Member-only story
Updating the flu analysis in England
This code gives an update to the ‘Covid By Numbers’ graph.
What has happened to influenza in England? Each week, the UK Health Security Agency publishes national flu and Covid-19 reports. These reports have many weekly series, including consultations with doctors in England.
A colourised version of a graph that appears in my co-written book looks like:
In that version, I used a prepared Excel file. Whilst people can download that one file, such code is not reproducible for future weeks. Analysts would have to mirror the same transformations, including dates.
Instead, we can use the curl package in R to download the ODS file which goes with each weekly report.
temp <- tempfile()
temp <- curl_download(url = ukhsa_url, destfile = temp, quiet = TRUE, mode = “wb”)
We then have to read that file. There is the readODS package for this purpose, with similar syntax to the Excel version. We need to create a column of dates, as the table lists weeks in chronological order. For this report, there are two weeks numbered 7 — referring to the same week a year apart.
ukhsa_fig33_tbl <- read_ods(temp, sheet = “Figure_33&34__Primary_care”,
range = ukhsa_fig33_range) %>%
janitor::clean_names() %>%…