library(tidyverse)5.2.a - Class Activity
This assignment is intended to get you familiar with the tidyverse using real COVID-19 data.
The following code chunk 1. Scrapes the .csv files we will be analyzing from the web 2. Renames columns 3. Selects the subset of columns that we will be using for analysis.
url <- "https://srhdpeuwpubsa.blob.core.windows.net/whdh/COVID/"
url_case <- paste0(url, "WHO-COVID-19-global-table-data.csv")
covid_case <- read_csv(url_case) |>
select(name = Name, region = `WHO Region`,
case_total = `Cases - cumulative total`,
case_pop = `Cases - cumulative total per 100000 population`,
death_total = `Deaths - cumulative total`,
death_pop = `Deaths - cumulative total per 100000 population`)The renamed columns that remain are:
name: Country nameregion: World Health Organization (WHO) region.case_total: Cumulative number of reported COVID cases since Jan 2020case_pop: Cumulative number of reported COVID cases per 100,000 people since Jan 2020death_total: Cumulative number of reported COVID deaths since Jan 2020death_pop: Cumulative number of reported COVID deaths per 100,000 people since Jan 2020
1 Countries in the Americas
We are interested in comparing COVID statistics from the United States to other large countries in our region. Please create a new data frame called covid_case_am which contains all countries in the “Americas” region. Use the pipe |> statement to help you complete the task.
How many countries are in this region? Please answer this question in the associated canvas quiz.
## covid_case_am <- covid_case |>
## filter(#...#)2 Case Fatality Rate
Within the “Americas” region, we want to know which countries had the highest percentage of deaths per reported case. This is calculated as \(100 * \frac{\text{deaths\_total}}{\text{case\_total}}\). Create a new variable called death_rate that reflects this quantity. Then, after calculating this quantity, retain only countries whose death rate exceeds 3% (or 3 deaths per 100 cases). Note that you do not need to save this dataframe to a variable, just show the output.
What are the three countries for which the death rate exceeds 3 deaths per 100 cases? Answer this question in the associated canvas quiz.
## covid_case_am <- covid_case_am |>
## mutate(#...#)
## covid_case_am |>
## filter(#...#)3 USA vs. Canada
Using the variable you created in the previous problem, create a dataframe that includes only the “United States of America” and “Canada”. Retain only the columns name, case_pop, death_pop, and death_rate.
What is the difference in the deaths per 100,000 people, rounded to the nearest integer?
Please answer in your canvas quiz.
## covid_case_am |>
## filter(#...#) |>
## select(#...#)4 Statistical Differences
Discuss with a partner: What do you notice about the difference in the Canadian and American statistics? Comment briefly below.
Replace this text with your answer. Optional if you verbally discuss this question with a partner but required if you do this assignment on your own.