-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot.R
158 lines (125 loc) · 4.43 KB
/
plot.R
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
myPalette <- colorRampPalette(brewer.pal(12, "Paired"))
############
### world
############
title.prediction <-
paste(
format(max(daily.cumulative.death$date), format = "%Y %B %d"),
" - Observed and predicted values with confidence intervals. Estimated date of the peak of the epidemic = triangle. Confinement date = circle with an X. "
)
title.prediction.norm <-
paste(
format(max(daily.cumulative.death$date), format = "%Y %B %d"),
" - Normalized data by population size of the country. Time 0 is ~2 deaths for 1 million.",
"data from https://github.com/CSSEGISandData/COVID-19."
)
title.daily.death <- paste(
format(max(daily.cumulative.death$date), format = "%Y %B %d"),
". Daily number of deaths.",
"data from https://github.com/CSSEGISandData/COVID-19."
)
#########################################################################################
p.prediction <- plot.prediction(
death.prediction = death.prediction,
countries.of.interest = countries.of.interest,
max.date.pred = max.date.pred,
y.lim.max = y.lim.max,
pic.value.all = pic.value.all,
confinement.date = confinement.date.top,
title.prediction = title.prediction
)
#########################################################################################
p.prediction.norm <-
plot.prediction.norm(
death.prediction = death.prediction,
countries.of.interest = countries.of.interest,
pic.value.all = pic.value.all,
confinement.date = confinement.date.top,
title.prediction.norm = title.prediction.norm
)
### number of death per day
ind.top <- which(daily.death$country %in% countries.of.interest)
p.daily.death <-
plot.daily.death(
daily.death = daily.death[ind.top, ],
countries.of.interest = countries.of.interest,
title.daily.death = title.daily.death
)
htmlwidgets::saveWidget(p.prediction,
"absolute.html",
selfcontained = FALSE,
libdir = "lib")
htmlwidgets::saveWidget(
p.prediction.norm,
"absolute.norm.html",
selfcontained = FALSE,
libdir = "lib"
)
htmlwidgets::saveWidget(p.daily.death,
"daily.html",
selfcontained = FALSE,
libdir = "lib")
##########
### USA
##########
usa.title.prediction <-
paste(
format(max(daily.cumulative.death$date), format = "%Y %B %d"),
" - USA - Observed and predicted values with confidence intervals. Estimated date of the peak of the epidemic = triangle. Confinement date = circle with an X. "
)
usa.title.prediction.norm <-
paste(
format(max(daily.cumulative.death$date), format = "%Y %B %d"),
"USA - Normalized data by population size of the state. Time 0 is ~2 deaths for 1 million.",
"data from https://github.com/CSSEGISandData/COVID-19."
)
usa.title.daily.death <- paste(
format(max(daily.cumulative.death$date), format = "%Y %B %d"),
". USA - Daily number of deaths.",
"data from https://github.com/CSSEGISandData/COVID-19."
)
#########################################################################################
usa.p.prediction <-
plot.prediction(
death.prediction = usa.death.prediction,
countries.of.interest = usa.countries.of.interest,
max.date.pred = max.date.pred,
y.lim.max = usa.y.lim.max,
pic.value.all = usa.pic.value.all,
confinement.date = NULL,
title.prediction = usa.title.prediction
)
#########################################################################################
usa.p.prediction.norm <-
plot.prediction.norm(
death.prediction = usa.death.prediction,
countries.of.interest = usa.countries.of.interest,
pic.value.all = usa.pic.value.all,
confinement.date = NULL,
title.prediction.norm = usa.title.prediction.norm
)
### number of death per day
usa.ind.top <-
which(usa.daily.death$country %in% usa.countries.of.interest)
usa.p.daily.death <-
plot.daily.death(
daily.death = usa.daily.death[usa.ind.top, ],
countries.of.interest = usa.countries.of.interest,
title.daily.death = usa.title.daily.death
)
htmlwidgets::saveWidget(
usa.p.prediction,
"usa.absolute.html",
selfcontained = FALSE,
libdir = "lib"
)
htmlwidgets::saveWidget(
usa.p.prediction.norm,
"usa.absolute.norm.html",
selfcontained = FALSE,
libdir = "lib"
)
htmlwidgets::saveWidget(usa.p.daily.death,
"usa.daily.html",
selfcontained = FALSE,
libdir = "lib")