-
Notifications
You must be signed in to change notification settings - Fork 0
/
output.Rmd
140 lines (131 loc) · 6.08 KB
/
output.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
---
title: "Graphs"
author: "VF"
date: "9 July 2020"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
Resulting graphs and cleaned and prepared data can be found at
https://drive.google.com/drive/folders/1Yo0IW4awCIvWMP6jYVKpn3kLgEolse0e?usp=sharing
for publication
```{r Init & load latest graph definitions and data, echo=FALSE}
rm(list = setdiff(ls(), c('ECDC0', 'JHH0', 'JHH', 'ECDC', 'JHHRegios', 'ECDCRegios','testing')))
options(warn = 0)
if (!exists('JHH')) source('loadData.R') else
if (max(JHH$Date) < Sys.Date() - 1) source('loadData.R') else source('definitions.R')
```
```{r save Rdata}
save.image(".RData") #D:/gits/Covid19/
```
Graph active_imputed, recovered, deaths, and confirmed for some selected territories,
based on JHH data:
```{r demo graph}
graphit(JHH, regios$Vincent, xvar = 'Date',
yvars = c('net_active_imputed','new_recovered','new_deaths','new_confirmed'),
facet = "PSCR", logy = TRUE,from = "2020-06-01")
```
```{r}
source("graphit.R")
graphit(JHH, regios$Vincent, xvar = 'day', logx = TRUE , logy = TRUE, from = "2020-07-01",
yvars = c('new_confirmed_p_M'), labmeth = 'repel_label', putlegend = FALSE)
graphit(JHH, regios$Vincent, xvar = 'day', logx = TRUE , logy = TRUE, from = "2020-07-01",
yvars = c('new_confirmed_p_M'), labmeth = 'repel_text')
graphit(JHH, regios$Vincent, xvar = 'day', logx = TRUE , logy = TRUE, from = "2020-07-01",
yvars = c('new_confirmed_p_M'), labmeth = 'dl_polygon')
graphit(JHH, regios$Vincent, xvar = 'day', logx = TRUE , logy = TRUE, from = "2020-07-01",
yvars = c('new_confirmed_p_M'), labmeth = 'dl_bumpup', putlegend = TRUE)
```
Show table outputs:
```{r latest numbers with most growth}
#show some data table output
#JHH[JHH$Date == max(JHH$Date),'Date'][1,1]
JHH %>% filter(Date == max(Date)) %>% filter(!is.nan(new_active_rate)) %>%
select(PSCR,confirmed, active_imputed, deaths, new_confirmed, new_active_rate, active_imputed_growthRate,
active_imputed_p_M) %>% arrange(new_active_rate) %>% tail(10)
```
and Countries we're interested in latest numbers:
```{r }
JHH[JHH$Date == max(JHH$Date) & JHH$PSCR %in%
c('EU','World',"Kazakhstan",'Belgium','Spain','US','Netherlands','Europe',
'Germany','France','Africa','Russia','Brazil'),
c('PSCR','active_imputed','active_imputed_p_M','new_deaths','new_confirmed',
'new_active_rate', 'active_imputed_growthRate','confirmed') ] %>%
arrange(new_active_rate)
```
Who overtakes us based the JHH data set on latest day data?
```{r overtaking 1, eval=FALSE, include=FALSE}
map_dfc(c('Kazakhstan','Belgium','Netherlands','Sweden'),
function(x) overtakeDays_df(JHH,x,who = 'theyme',lastDays = 1))
```
And on 7 day averages in JHH?
```{r overtaking week based}
map_dfc(c('Kazakhstan','Belgium','Netherlands','Sweden'),
function(x) overtakeDays_df(JHH,x,who = 'theyme',lastDays = 7))
```
And according to ECDC?
```{r overtaking based on ECDC}
map_dfc(c('Kazakhstan','Belgium','Netherlands','Sweden'),
function(x) overtakeDays_df(ECDC,x,who = 'theyme',lastDays = 7))
```
Who is more affected?
```{r graph it}
graph3Dard_fia(ECDC, c('Kazakhstan','Belgium','Netherlands','Sweden'))
graph3Dard_fina(ECDC, c('Kazakhstan','Belgium','Netherlands','Sweden'))
```
Who do we overtake?
```{r we overtake}
map_dfc(c('Kazakhstan','Belgium','Netherlands','Sweden'),function(x) overtakeDays_df(JHH,x,who = 'Ithem',lastDays = 7))
map_dfc(c('Kazakhstan','Belgium','Netherlands','Sweden'),function(x) overtakeDays_df(ECDC,x,who = 'Ithem',lastDays = 7))
```
Lets see who is going to overtake the UK, France, or GErmany soon:
```{r UK France Germany}
graph3Dard_fia(JHH, c('Germany','France','United Kingdom'))
graph3Dard_fina(JHH, c('Germany','France','United Kingdom'))
map_dfc(c('Germany','France','United Kingdom'), function(x) overtakeDays_df(JHH,x,who = "theyme", lastDays = 7))
map_dfc(c('Germany','France','United Kingdom'), function(x) overtakeDays_df(JHH,x,who = "Ithem", lastDays = 7))
```
Not overtaking anyone does not mean the epidemic is under control. It just means your epidemic is alsready larger than all states that grow slower. It also means you have better control than more severely touched territories.
For New York state, Indonesia, Peru, India:
```{r NY Id In Pe}
graph3Dard_fina(JHH, c('New York,US','California,US','Florida,US','Texas,US','Peru',"Arizona,US"))
map_dfc(c('New York,US','California,US','Florida,US','Texas,US','Peru',"Arizona,US"),
function(x) overtakeDays_df(JHH,x,who = 'Ithem'))
map_dfc(c('New York,US','California,US','Florida,US','Texas,US','Peru',"Arizona,US"),
function(x) overtakeDays_df(JHH,x,who = 'theyme'))
```
See how the most affected regions in the world are developing: (pop the graph out to a new window and enlarge to see more detail)
```{r most affected graph}
graph6Dardcra_finyl(JHH, JHHRegios$`JHH World1`)
```
```{r deaths and recovered by confirmed}
graph2crd_il(JHH,JHHRegios$`JHH Europe3`)
graph2crd_il(JHH,JHHRegios$`JHH Europe2`)
graph1dnar_iyl(JHH, JHHRegios$`JHH Europe2`)
graphit(JHH, JHHRegios$`JHH Europe2`, minVal=1, xvar = 'day',
yvars = c('new_active_rate'), logy = TRUE, intercept = stableRate)
```
If you want to write the data to disk, make sure to define the correct datapath so that R can write to it. By default it is a subfolder of the scripts folder. Note that the data will also be written to a subfolder of the plots folder.
``` {r save the data}
dataPath <- './data'
if (!dir.exists(dataPath)) dir.create(dataPath, recursive = TRUE)
writeWithCounters(ECDC,name = "Covid19ECDC")
writeWithCounters(JHH,name = "Covid19JHH")
```
The motor in all this is the graphit function. It is quite powerful but hass a lot of parameters. Several functions preset some parameters, Below a lost of Graphs defined.
```{r show the system}
setdiff(myGraphList, c(myGraphListbyDate, myGraphListbyDay, myGraphNrs))
c( myGraphListbyDate, myGraphListbyDay, myGraphNrs)
```
There is a system in the naming:
```{r}
graphCodes()
```
```{r setup Python}
Sys.which("python")
use_python("path/to/python")
```
```{python eval=FALSE, include=FALSE}
2^100
```