knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
The {covidvirus} package comes with one function get_cases()
that retrieves a daily snapshot of confirmed, death, and recovered cases from the Johns Hopkins University Center for Systems Science and Engineering (JHU CCSE) Coronavirus repository.
library(covidvirus) corona_virus <- covidvirus::get_cases()
The retrieved data consists of the following columns:
province_state
: the province or state within the country (if applicable)country-region
: the country or region namelat
: the latitudelong
: the longitudedate
: the date of the summarytype
: the classification of the case (e.g., infected, death, recovered)cases
: the total number of cases observed dailyThe returned dataset is a tibble and we can easily leverage any tidyverse compatible function.
Let's take a look at the first few rows and the structure:
head(corona_virus)
dplyr::glimpse(corona_virus)
Let's dive a bit into the data. We'll use the following libraries: dplyr
.
library(dplyr)
corona_virus %>% group_by(type) %>% summarize( total_cases = sum(cases) ) %>% ungroup()
corona_virus %>% group_by(country_region) %>% summarize( total_cases = sum(cases) ) %>% ungroup() %>% arrange(desc(total_cases))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.