@@ -30,7 +30,7 @@ library(dplyr)
3030
3131To get data on official Covid-19 statistics, we will use the [ ` COVID19 ` ] ( https://github.com/covid19datahub/COVID19 ) R package.
3232
33- ![ ] ( https://camo.githubusercontent.com/b627e2aa6edcee3ead77511a35d4e1a5e91aa07f/68747470733a2f2f73746f726167652e636f7669643139646174616875622e696f2f6c6f676f2e737667 )
33+ < img src = " https://camo.githubusercontent.com/b627e2aa6edcee3ead77511a35d4e1a5e91aa07f/68747470733a2f2f73746f726167652e636f7669643139646174616875622e696f2f6c6f676f2e737667 " width = " 50% " style = " display : block ; margin : auto ; " >
3434
3535This package provides daily updated data on a variety of variables related to the coronavirus pandemic at national, regional and city levels.
3636Install it as follows:
@@ -74,7 +74,6 @@ world_projected = world_rnatural %>%
7474plot(world_projected)
7575```
7676
77-
7877``` {r}
7978w = dplyr::left_join(world_projected, d, by = c("ISO_A3_EH"= "id"))
8079w_today = w[w$date == Sys.Date() - 1, ]
@@ -99,11 +98,15 @@ tm_shape(w_today) +
9998
10099``` {r}
101100tm_shape(w_today) +
102- tm_polygons(c("deaths", "recovered"), palette = "viridis", style = "log10_pretty")
101+ tm_polygons(c("deaths", "recovered"),
102+ palette = "viridis", style = "log10_pretty")
103103```
104104
105105``` {r}
106106g = st_graticule(w_today)
107+ ```
108+
109+ ``` {r}
107110tm_shape(g) +
108111 tm_lines(col = "grey") +
109112 tm_shape(w_today) +
@@ -120,7 +123,11 @@ tm_shape(g) +
120123tm_shape(g) +
121124 tm_lines(col = "grey") +
122125 tm_shape(w_today) +
123- tm_polygons(c("deaths", "recovered"), palette = "viridis") +
126+ tm_polygons(
127+ c("deaths", "recovered"),
128+ palette = "viridis",
129+ style = "log10_pretty"
130+ ) +
124131 tm_layout(legend.position = c(0.01, 0.25)) +
125132 tm_shape(w_today) +
126133 tm_dots(size = c("deaths", "recovered"), col = c("red", "green"))
@@ -131,8 +138,11 @@ w$Date = as.character(w$date)
131138tm_shape(g) +
132139 tm_lines(col = "grey") +
133140 tm_shape(w_today) +
134- tm_polygons(c("deaths"), palette = "viridis") +
135- tm_layout(legend.position = c(0.01, 0.25)) +
141+ tm_polygons(
142+ c("deaths", "recovered"),
143+ palette = "viridis",
144+ style = "log10_pretty"
145+ ) +
136146 tm_shape(w %>% filter(date > Sys.Date() - 4)) +
137147 tm_dots(size = c("deaths"), col = c("red")) +
138148 tm_facets("Date")
@@ -144,11 +154,15 @@ To create an animated map, following instructions in Chapter [8](https://geocomp
144154m = tm_shape(g) +
145155 tm_lines(col = "grey") +
146156 tm_shape(w_today) +
147- tm_polygons(c("deaths"), palette = "viridis") +
148- tm_layout(legend.position = c(0.01, 0.25)) +
157+ tm_polygons(
158+ c("deaths", "recovered"),
159+ palette = "viridis",
160+ style = "log10_pretty"
161+ ) +
149162 tm_shape(w %>% filter(date > Sys.Date() - 4)) +
150163 tm_dots(size = c("deaths"), col = c("red")) +
151- tm_facets(along = "Date", free.coords = FALSE)
164+ tm_facets(along = "Date", free.coords = FALSE) +
165+ tm_layout(legend.position = c(0.01, 0.25))
152166tmap_animation(m, "covid-19-animated-map-test.gif", width = 800)
153167browseURL("covid-19-animated-map-test.gif")
154168```
@@ -158,27 +172,34 @@ Not bad, but would benefit from a few adjustments before we plot the results of
158172``` {r, eval=FALSE}
159173world_projected$Area_km = as.numeric(st_area(world_projected)) / 1e6
160174world_projected$`Pop/km2` = as.numeric(world_projected$POP_EST) / world_projected$Area_km
161- b = c(0, 100, 200, 400, 800, 16000)
162175
163176m = tm_shape(g) +
164177 tm_lines(col = "grey") +
165178 tm_shape(world_projected) +
166- tm_polygons("Pop/km2", palette = "viridis", breaks = b) +
167- tm_layout(legend.position = c(0.01, 0.25)) +
179+ tm_polygons(
180+ "Pop/km2",
181+ palette = "viridis",
182+ style = "log10_pretty",
183+ lwd = 0.5
184+ ) +
168185 tm_shape(w %>% filter(date > Sys.Date() - 60)) +
169186 tm_dots(size = c("deaths"), col = c("red")) +
170187 tm_facets(along = "Date", free.coords = FALSE) +
171188 tm_layout(legend.outside = TRUE)
172- tmap_animation(m, "covid-19-animated-map.gif", width = 1200)
189+ tmap_animation(m, "covid-19-animated-map.gif", width = 1200, height = 800 )
173190browseURL("covid-19-animated-map.gif")
174-
175191```
176192
193+ <!-- update the file below-->
194+
177195![ ] ( https://user-images.githubusercontent.com/1825120/79768034-1e60ab80-8322-11ea-9c99-9997b588ee57.gif )
178196
197+ <details >
179198
199+ <summary >Session info</summary >
180200
181201``` {r sessioninfo}
182202devtools::session_info()
183203```
184204
205+ </details >
0 commit comments