1 Introduction

It was March 2020, still traumatized that Andrew Yang drop-out from the presidential race. The only candidate that is data informed and very original. The other headline news during this time frame were about Syrian Civil War, Coronavirus pandemic, European migrant crisis, and the presidential race in the United States (Wikipedia 2020).

I was very optimistic that the United States will not have a pandemic in any of its states or properties. At the same time, I was amazed at the many dashboards that were created to monitor the spread of Covid-19 globally. Below is an example code of how easy it is to pull information and create a visual map.

library(COVID19)
library(dplyr)
library(DT)
library(knitr)
library(kableExtra)

# grab data from library COVID19
X <- covid19(verbose = FALSE)

MarchCovid <- X %>% 
  filter(date == "2020-03-31") %>% 
  select(
    administrative_area_level_1,
    date,
    confirmed,
    recovered,
    deaths) %>% 
  arrange(desc(confirmed)) %>% 
    rename(country = 
             administrative_area_level_1)

## Turn to table
MarchCovid[1:10, ] %>% 
  kable(caption = 'March 2020 Covid19 Metrics') %>%   
  kable_styling()
Table 1.1: March 2020 Covid19 Metrics
id country date confirmed recovered deaths
USA United States 2020-03-31 188724 7024 5718
ITA Italy 2020-03-31 105792 15729 12428
ESP Spain 2020-03-31 95923 19259 8464
CHN China 2020-03-31 82545 0 3314
DEU Germany 2020-03-31 74132 71477 2653
FRA France 2020-03-31 52128 9444 0
IRN Iran 2020-03-31 44605 14656 2898
GBR United Kingdom 2020-03-31 25521 135 2453
BEL Belgium 2020-03-31 16981 1696 1377
CHE Switzerland 2020-03-31 16605 1823 433

I started the Data Science Specialization when Covid-19 cases were below 200,000 in the US. These numbers affected people’s lives, their families, loved ones and neighbors. It changes the way we shop, travel, and live. It made us value our homes and the kitchen became the center of the house again.

Map visualization can be accomplish with many packages available in R. One of them is called leaflet package and below will show us how aggressive the spread of Covid19 throughout the globe during the end of March 2020.

library(leaflet)
library(viridisLite)
library(viridis)

# Create a map using Leaflet
mapVisData <- X %>% 
  filter(date == "2020-03-31") %>%    
  rename(country=
           administrative_area_level_1)  %>% 
  select(country,
          date,
          longitude,
          latitude,
          confirmed,
          recovered,
          deaths)

# Color code with viridislite and viridis
CountryColor <- colorFactor(
  viridis(76), 
  mapVisData$country)

Figure_1.1 <- leaflet(
  data = mapVisData) %>% 
  addTiles() %>% 
  setView(lng = 26.8206,
        lat = 30.8025,
        zoom = 2) %>% 
  addCircleMarkers(
     ~ longitude,
     ~ latitude,
     popup = paste(
     "Country: ",prettyNum(
       mapVisData$country, 
       big.mark = ","), 
     "<br>",
     "Confirmed: ",prettyNum(
       mapVisData$confirmed, 
       big.mark = ","), 
     "<br>",
     "Recovered: ", prettyNum(
       mapVisData$recovered, 
       big.mark = ","), 
     "<br>",
     "Deaths: ", prettyNum(
       mapVisData$deaths, 
       big.mark = ",")),
   weight = 1,
   radius = ~ sqrt(confirmed)*.1,
   stroke = FALSE,
   fillOpacity = .7,
   fillColor = ~CountryColor(country)
) 
Figure_1.1

Figure 1.1: End of March - Covid19 (RStudio Leaflet Team 2020)

At the beginning of the class, I was not able to code the way I code in R now. The progression and knowledge skills increase as I consume more of the information. Again, I had vivid dreams while taking these classes and if you decided to pursue the same route, may you have the sweetest of all dreams. I hope this book gets you through the night.

References

RStudio Leaflet Team. 2020. “Leaflet for R.” https://rstudio.github.io/leaflet/.

Wikipedia. 2020. “Portal:Current Events/March 2020.” Wikipedia, The Free Encyclopedia. https://en.wikipedia.org/wiki/Portal:Current_events/March_2020.