The CDC has been continuously tracking the novel Coronavirus outbreak since December, 2019. The following analysis will be performed on the data obtained between January 21, 2020 to March 12, 2020.
The following data was obtained from Kaggle, a website full of helpful resources and free datasets. In order to analyze Coronavirus cases, I used the filter() function to only include confirmed cases in my data frame. Additionally, to compare cases against deaths in the graph, I used the Leaflet icon found on the Leaflet website to include red and green leaves as you zoom in on the clusters.
library(leaflet)
## Warning: package 'leaflet' was built under R version 4.0.5
library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.0 --
## v ggplot2 3.3.3 v purrr 0.3.4
## v tibble 3.0.5 v dplyr 1.0.3
## v tidyr 1.1.2 v stringr 1.4.0
## v readr 1.4.0 v forcats 0.5.0
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
data = read.csv("C:/Users/raega/Documents/Intro to R/Data/CV_LatLon_21Jan_12Mar.csv")
data=data %>%
filter(confirmed>0)
leafIcons <- icons(
iconUrl = ifelse(data$death > 0,
"http://leafletjs.com/examples/custom-icons/leaf-red.png",
"http://leafletjs.com/examples/custom-icons/leaf-green.png"
),
iconWidth = 38, iconHeight = 95,
iconAnchorX = 22, iconAnchorY = 94,
shadowUrl = "http://leafletjs.com/examples/custom-icons/leaf-shadow.png",
shadowWidth = 50, shadowHeight = 64,
shadowAnchorX = 4, shadowAnchorY = 62
)
html_legend <- "<img src='http://leafletjs.com/examples/custom-icons/leaf-green.png'>case<br/>
<img src='http://leafletjs.com/examples/custom-icons/leaf-red.png'>death"
The map shows cases of the Coronavirus worldwide. Once zoomed in on the clusters, each leaf counts as an individual case, while red leaves show cases that resulted in death.
data %>%
leaflet() %>%
addTiles() %>%
addMarkers(~lon, ~lat,clusterOptions=markerClusterOptions(), icon = leafIcons) %>%
addControl(html = html_legend, position = "bottomleft")