Last active
December 15, 2021 16:25
-
-
Save theosanderson/5abac30e72676c839849bb84d82c08c2 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) | |
cases <- read_csv("https://api.coronavirus.data.gov.uk/v2/data?areaType=region&areaCode=E12000007&metric=newCasesBySpecimenDate&format=csv") | |
sgtf = read_csv("https://gist.githubusercontent.com/theosanderson/3443a0982d52283e6443f191a6a19d92/raw/118ec9dd4adb6f538c75b097ac0cc0ae66dcf655/LondonSGTF.csv", col_names = c("date","sgtf100")) %>% mutate(sgtf=sgtf100/100) %>% group_by(date) %>% summarise(sgtf=mean(sgtf)) | |
both = full_join(cases,sgtf) %>% mutate(sgtf = ifelse(is.na(sgtf),0,sgtf),sgtf_cases = newCasesBySpecimenDate*sgtf,nonsgtf_cases = newCasesBySpecimenDate*(1-sgtf)) %>% select(date, sgtf_cases,nonsgtf_cases) %>% pivot_longer(-date) %>% mutate(variant=ifelse(name=="sgtf_cases","Omicron","Delta")) | |
both | |
ggplot(both %>% filter(date>"2021-6-1", date<="2021-12-11", date<= max(sgtf$date)),aes(x=date,color=variant,y=value))+geom_line() +theme_classic()+labs(x="Specimen date",y="Cases")+theme_bw()+scale_x_date(breaks=scales::pretty_breaks(6)) +scale_color_manual(values=c("#377eb8","#e41a1c","")) +labs(color="",title="Cases in London by specimen date and variant", caption="Data: UKHSA. SGTF proportions traced from daily update graph \nand combined with case numbers from coronavirus.data.gov.uk.") | |
ggsave("variants.pdf",width=6, height =4) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for making this publicly available. :)