-
Notifications
You must be signed in to change notification settings - Fork 1
/
walomb_plot.Rmd
71 lines (60 loc) · 2.36 KB
/
walomb_plot.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
62
63
64
65
66
67
68
---
title: "Lombardy vs WA Plots"
date: "`r format(Sys.Date(), '%A %b %d, %Y')`"
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
```{r, message=FALSE, warning=FALSE}
library(CoV19)
```
```{r italy_plot, message=FALSE, warning=FALSE}
p <- my_plot(italy, "Lombardia", "2020-03-10")
p + geom_vline(xintercept = as.Date("2020-05-04"), linetype = "dashed") +
annotate("text", x=as.Date("2020-05-04")+0.5, y=42000, hjust=0, label="lockdown eased", color="red", size=3, angle=90, vjust=1)
```
```{r wa_plot, message=FALSE, warning=FALSE}
x <- subset(world, region=="Washington US")
# tmp <- x[1,]
# tmp$date <- as.Date("2020-04-04")
# tmp[1,!colnames(tmp) %in% c("date", "region")] <- NA
# tmp$positive <- 7984; tmp$death <- 308
# x <- rbind(x, tmp)
reg <- "Washington US"
p <- my_plot(x, reg) + xlim(as.Date("2020-03-01"), Sys.Date())
p <- add_vline(p, "restaurants close", "2020-03-16")
p <- add_vline(p, "12 days past restaurants closed", "2020-03-28", linetype="dashed")
p <- add_vline(p, "stay at home order", "2020-03-23")
p <- add_vline(p, "SIP eased - parks open", "2020-05-08", linetype="dashed")
p
```
```{r king_plot, message=FALSE, warning=FALSE}
reg = "King Washington US"
p <- my_plot(world, reg) + xlim(as.Date("2020-03-01"), Sys.Date())
p <- add_vline(p, "restaurants close", "2020-03-16")
p <- add_vline(p, "12 days past restaurants closed", "2020-03-28", linetype="dashed")
p <- add_vline(p, "stay at home order", "2020-03-23")
p <- add_vline(p, "SIP eased - parks open", "2020-05-08", linetype="dashed")
p
```
```{r}
b=subset(states, region=="WA")
tmp=diff(b$total.tests)
plot(b$date[-1], zoo::rollapply(tmp,7,mean,fill=NA),type="l",ylab="tests (7-day average)", xlab="")
par(new=TRUE)
tmp=diff(b$positive)/diff(b$total.tests)
tmp[b$date[-1]<as.Date("2020-03-03")] <- NA
plot(b$date[-1], 100*zoo::rollapply(tmp,7,mean,na.rm=TRUE,fill=NA),yaxt="n", ylab="", ylim=c(0,20), type="l", lwd=2, col="blue")
axis(4)
title("WA 7-day (rolling) averages")
legend("topleft", c("# of tests (left)", "% positive (right)"), lwd=c(1,2), col=c("black", "blue"))
```
```{r world_plot, message=FALSE, warning=FALSE}
reg = unique(world$region[str_detect(world$region, "Washington US")])
reg <- reg[-1*(40:42)]
for(i in reg){
if(max(subset(world, region==i)$positive, na.rm=TRUE)<100) next
p <- my_plot(world, i) + xlim(as.Date("2020-03-01"), Sys.Date())
if(!is.null(p)) plot(p)
}
```