Last active
July 31, 2020 19:48
-
-
Save sjcockell/2328dda4d48174940758876251b4c443 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(zoo) | |
read_csv('https://coronavirus.data.gov.uk/downloads/csv/coronavirus-cases_latest.csv') %>% | |
dplyr::filter(`Area type` == 'Upper tier local authority') %>% | |
dplyr::arrange(desc(`Area name`)) %>% | |
dplyr::group_by(desc(`Area name`)) %>% | |
dplyr::mutate(`Cases - 7 day rolling average` = zoo::rollmean(`Daily lab-confirmed cases`, k = 7, fill = NA)) %>% | |
dplyr::ungroup() %>% | |
dplyr::filter(`Area name` %in% c('Gateshead', 'Newcastle upon Tyne')) %>% | |
ggplot(aes(x=`Specimen date`, y=`Cases - 7 day rolling average`, group=`Area name`)) + | |
geom_line(aes(colour=`Area name`)) + | |
geom_line(aes(y=`Daily lab-confirmed cases`, colour=`Area name`), alpha=0.4) + | |
theme_bw() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment