Covid-19 Data

Daily summary of the Covid-19 cases per state/region

Anne Sophie Gill https://www.skemagloballab.io/gillAnneSophie.html (SKEMA Global Lab in AI)https://skemagloballab.io , Marine Leroi https://www.skemagloballab.io/leroiMarine.html (SKEMA Global Lab in AI)https://skemagloballab.io , Thierry Warin https://www.nuance-r.com/principalInvestigator.html (SKEMA Business School (Raleigh, NC))https://www.skemagloballab.io
03-02-2020

Using the SKEMA Quantum Studio(Warin 2019) framework, we will teach you how to use the {covidvirus} package.

The {covidvirus} package provides a tidy format dataset of the 2019 Novel Coronavirus COVID-19 (2019-nCoV) epidemic. The raw data pulled from the Johns Hopkins University Center for Systems Science and Engineering (JHU CCSE) Coronavirus repository.

The {covidvirus} package was inspired by Rami Krispin’s {coronavirus} package. The key difference is that Rami’s package provides a dataset which must be manually updated from the package author’s perspective. In this package, Nik Agarwal used (i.e, respectfully copied) Rami Krispin’s data retrieval code and modified it to use substantially more “tidyverse” packages such as {janitor}, {lubridate}, etc. Another key difference is the name of columns. Since Nik used the package {janitor}, the column names use a ‘snake’ style and do not have dots ‘.’ (opting for the underscore ’_’).

COVIDVIRUS PACKAGE

Nik Agarwal covidvirus

CORONAVIRUS PACKAGE

Rami Krispin coronavirus

How to use the covidvirus package

Installation

You can install the development version from GitHub with :


# install.packages("devtools")
# devtools::install_github("nikdata/covidvirus")

Usage

This is a basic example which shows you how to solve a common problem :


library(covidvirus)
corona_virus <- get_cases(wide=FALSE)

library(dplyr)
library(leaflet)
library(leaflet.extras)

Data Wrangling


# rename the country region
corona_virus$country_region <- gsub("United States", "USA", corona_virus$country_region)
corona_virus$country_region <- gsub("Mainland China", "China", corona_virus$country_region) 

# if the province state in the column is NA, paste the country region name in the column
corona_virus$name <- ifelse(is.na(corona_virus$province_state) == TRUE, 
                                paste0(corona_virus$country_region), paste0(corona_virus$province_state))

#filter the data
corona_virus <- filter(corona_virus, type == "confirmed")
corona_virus <- filter(corona_virus, date == "2020-04-02")

# ifelse ladder statement
corona_virus$category <- ifelse(corona_virus$cases >= -1 & corona_virus$cases <= 0, 0,
                                   ifelse(corona_virus$cases >= 1 & corona_virus$cases <= 10, 1,
                                   ifelse(corona_virus$cases >= 11 & corona_virus$cases <= 100, 2,
                                   ifelse(corona_virus$cases >= 101 & corona_virus$cases <= 1000, 5,
                                   ifelse(corona_virus$cases >= 1001 & corona_virus$cases <= 5000, 8,
                                   ifelse(corona_virus$cases >= 5001 & corona_virus$cases <= 10000, 10,
                                   ifelse(corona_virus$cases >= 10001 & corona_virus$cases <= 50000, 12,
                                   ifelse(corona_virus$cases >= 50001 & corona_virus$cases <= 100000, 15,
                                   ifelse(corona_virus$cases >= 100001 & corona_virus$cases <= Inf, 20,25)))))))))

Visualize your Data


content <- paste("<strong>", corona_virus$name, "</strong>", "<br/>", corona_virus$cases, "Cases")

leaflet(corona_virus) %>% 
  addFullscreenControl() %>%
  addProviderTiles(providers$CartoDB.DarkMatter) %>%
  addCircleMarkers(
    radius = ~sqrt(category)*5, popup = content,
    color = "red",
    stroke = FALSE, fillOpacity = 0.3
  )


We hope this helped you understand how to use the {covidvirus} package.


Coronavirus COVID-19 Global Cases by John Hopkins CSSE

Mapping 2019-nCoV


Follow SKEMA Global Lab in Augmented Intelligence

Warin, Thierry. 2019. “SKEMA Quantum Studio: A Technological Framework for Data Science in Higher Education.” https://doi.org/10.6084/m9.figshare.8204195.v2.

Citation

For attribution, please cite this work as

Gill, et al. (2020, March 2). Blog: Covid-19 Data. Retrieved from https://blog.skemagloballab.io/posts/2020-03-02-covidvirus/

BibTeX citation

@misc{gill2020covid-19,
  author = {Gill, Anne Sophie and Leroi, Marine and Warin, Thierry},
  title = {Blog: Covid-19 Data},
  url = {https://blog.skemagloballab.io/posts/2020-03-02-covidvirus/},
  year = {2020}
}