forked from ldanon/MetaWards
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathregionalplot.Rmd
61 lines (42 loc) · 1.42 KB
/
regionalplot.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
---
title: "Reagional Model Plots"
output: html_notebook
---
```{r}
library(tidyverse)
library(tidyverse)
library(gghighlight)
library(purrr)
library(plotly)
library(cowplot)
library(scales)
```
```{r}
wardlookup<-read.csv('~/GitHub/MetaWards/data/2011/WardsProcessing/Ward_Lookup.csv')
lad2region<-read.csv('~/GitHub/MetaWards/data/2011/WardsProcessing/Output_Area_2011_to_Builtup_Area_Subdivision_to_Builtup_Area_to_Local_Authority_District_to_Region_December_2011_Lookup_in_England_and_Wales.csv') %>%
group_by(LAD11CD) %>%
summarise(Region=unique(RGN11NM))
wardlookupregion<-wardlookup %>%
inner_join(.,lad2region, by=("LAD11CD"))
allinfections=read.table(file='Testing/BrigthonNewOutput/ForMattData.dat',sep = ' ')
allinfections %>% # make long data frame
mutate(Time=row_number()) %>% # count up time, as row number
pivot_longer(-Time) %>%
mutate(Ward=as.integer(str_remove(name,'V'))) %>%
select(-name)->inf_long # rename name to Ward integers for easier matching
wardlookupregion %>%
inner_join(.,inf_long, by=c('FID'='Ward'),all.y=T,all.x=F) %>%
group_by(Region,Time)%>%
summarise(Cases=sum(value)) -> region_inf
region_inf%>%
group_by(Region) %>%
summarise(PeakTime=which.max(Cases),PeakCases=max(Cases))
```
# Plot region epidemics in ggplot
```{r}
region_inf %>%
filter(Time<250) %>%
ggplot(aes(x=Time,y=Cases,colour=Region)) +
geom_line(size=2,alpha=0.5)+
theme_minimal_grid()
```