2021-01-03
library(data.table)
library(tmap)
library(ggmap)
library(geojsonio)
library(tidyverse)
<- fread("https://api.coronavirus.data.gov.uk/v2/data?areaType=msoa&metric=newCasesBySpecimenDateRollingRate&metric=newCasesBySpecimenDateChangePercentage&metric=newCasesBySpecimenDateDirection&format=csv")
msoa <- msoa[date == max(date), ] msoa1
::skim(msoa1) skimr
Name | msoa1 |
Number of rows | 6791 |
Number of columns | 13 |
_______________________ | |
Column type frequency: | |
character | 10 |
Date | 1 |
numeric | 2 |
________________________ | |
Group variables | None |
Data summary
Variable type: character
skim_variable | n_missing | complete_rate | min | max | empty | n_unique | whitespace |
---|---|---|---|---|---|---|---|
regionCode | 0 | 1 | 9 | 9 | 0 | 9 | 0 |
regionName | 0 | 1 | 6 | 24 | 0 | 9 | 0 |
UtlaCode | 0 | 1 | 9 | 9 | 0 | 149 | 0 |
UtlaName | 0 | 1 | 4 | 35 | 0 | 149 | 0 |
LtlaCode | 0 | 1 | 9 | 9 | 0 | 315 | 0 |
LtlaName | 0 | 1 | 4 | 35 | 0 | 315 | 0 |
areaType | 0 | 1 | 4 | 4 | 0 | 1 | 0 |
areaCode | 0 | 1 | 9 | 9 | 0 | 6791 | 0 |
areaName | 0 | 1 | 3 | 48 | 0 | 6728 | 0 |
newCasesBySpecimenDateDirection | 0 | 1 | 0 | 4 | 26 | 4 | 0 |
Variable type: Date
skim_variable | n_missing | complete_rate | min | max | median | n_unique |
---|---|---|---|---|---|---|
date | 0 | 1 | 2020-12-29 | 2020-12-29 | 2020-12-29 | 1 |
Variable type: numeric
skim_variable | n_missing | complete_rate | mean | sd | p0 | p25 | p50 | p75 | p100 | hist |
---|---|---|---|---|---|---|---|---|---|---|
newCasesBySpecimenDateRollingRate | 26 | 1 | 465.88 | 315.42 | 28.7 | 231.4 | 363.5 | 631.9 | 1893.2 | ▇▅▂▁▁ |
newCasesBySpecimenDateChangePercentage | 26 | 1 | 45.54 | 86.58 | -84.4 | -5.6 | 25.0 | 70.6 | 1400.0 | ▇▁▁▁▁ |
<- "https://opendata.arcgis.com/datasets/826dc85fb600440889480f4d9dbb1a24_0.geojson"
shp
<- rev(viridis::viridis(15))
palette <- viridis::viridis(4, direction = -1)
palette1 <- "Contains ordnance survey data © \nCrown copyright and database right 2020"
credits
## Download the data and convert to spatial polygon data frame
<- geojson_read(shp, what = "sp")
geodata
# glimpse(geodata)
## Select England wards
<- subset(geodata, substr(msoa11cd, 1, 1) == "E")
seng
## Join data to plot
@data <- left_join(seng@data, msoa1, by=c("msoa11cd" = "areaCode")) seng
<- tm_shape(seng) +
u tm_fill("newCasesBySpecimenDateDirection", style = "kmeans", palette = palette1 , n = 10,
title = "Direction") +
tm_credits( credits, size = 0.5, align = "right") +
tm_layout(legend.outside = TRUE,
frame = FALSE) +
tm_compass(position = c("left", "center")) +
tm_scale_bar(position = c("left", "center"))
u
## Linking to GEOS 3.7.2, GDAL 2.4.2, PROJ 5.2.0
<- tm_shape(seng) +
v tm_fill("newCasesBySpecimenDateChangePercentage", style = "kmeans", palette = palette , n = 10,
title = "% change") +
tm_credits( credits, size = 0.5, align = "right") +
tm_layout(legend.outside = TRUE,
frame = FALSE) +
tm_compass(position = c("left", "center")) +
tm_scale_bar(position = c("left", "center"))
v
<- tm_shape(seng) +
w tm_fill("newCasesBySpecimenDateRollingRate", style = "fisher", palette = palette , n = 10,
title = "Rate") +
tm_credits( credits, size = 0.5, align = "right") +
tm_layout(legend.outside = TRUE,
frame = FALSE) +
tm_compass(position = c("left", "center")) +
tm_scale_bar(position = c("left", "center"))
w