Intro

For this week’s homework, let’s work on mapping the covid-19 data. You have two choices of data source. The first is the coronavirus data we have already loaded.

library(coronavirus)
head(coronavirus)
##         date province country     lat      long      type cases   uid iso2 iso3
## 1 2020-01-22  Alberta  Canada 53.9333 -116.5765 confirmed     0 12401   CA  CAN
## 2 2020-01-23  Alberta  Canada 53.9333 -116.5765 confirmed     0 12401   CA  CAN
## 3 2020-01-24  Alberta  Canada 53.9333 -116.5765 confirmed     0 12401   CA  CAN
## 4 2020-01-25  Alberta  Canada 53.9333 -116.5765 confirmed     0 12401   CA  CAN
## 5 2020-01-26  Alberta  Canada 53.9333 -116.5765 confirmed     0 12401   CA  CAN
## 6 2020-01-27  Alberta  Canada 53.9333 -116.5765 confirmed     0 12401   CA  CAN
##   code3    combined_key population continent_name continent_code
## 1   124 Alberta, Canada    4413146  North America             NA
## 2   124 Alberta, Canada    4413146  North America             NA
## 3   124 Alberta, Canada    4413146  North America             NA
## 4   124 Alberta, Canada    4413146  North America             NA
## 5   124 Alberta, Canada    4413146  North America             NA
## 6   124 Alberta, Canada    4413146  North America             NA

The second is a newer dataset. It harvests data that is from the New York Times. It is focused solely on the US. To install it, you’ll need to do the following

#if you don't have it already
install.packages("devtools")

#install the library from github
devtools::install_github("covid19R/covid19nytimes")
library(covid19nytimes)
covid_states <- refresh_covid19nytimes_states()

head(covid_states)
## # A tibble: 6 × 7
##   date       location   location_type location_code location_code_type data_type
##   <date>     <chr>      <chr>         <chr>         <chr>              <chr>    
## 1 2023-03-23 Alabama    state         01            fips_code          cases_to…
## 2 2023-03-23 Alabama    state         01            fips_code          deaths_t…
## 3 2023-03-23 Alaska     state         02            fips_code          cases_to…
## 4 2023-03-23 Alaska     state         02            fips_code          deaths_t…
## 5 2023-03-23 American … state         60            fips_code          cases_to…
## 6 2023-03-23 American … state         60            fips_code          deaths_t…
## # ℹ 1 more variable: value <dbl>
covid_counties <- refresh_covid19nytimes_counties()

head(covid_counties)
## # A tibble: 6 × 7
##   date       location   location_type location_code location_code_type data_type
##   <date>     <chr>      <chr>         <chr>         <chr>              <chr>    
## 1 2022-05-13 Abbeville… county        45001         fips_code          cases_to…
## 2 2022-05-13 Abbeville… county        45001         fips_code          deaths_t…
## 3 2022-05-13 Acadia,Lo… county        22001         fips_code          cases_to…
## 4 2022-05-13 Acadia,Lo… county        22001         fips_code          deaths_t…
## 5 2022-05-13 Accomack,… county        51001         fips_code          cases_to…
## 6 2022-05-13 Accomack,… county        51001         fips_code          deaths_t…
## # ℹ 1 more variable: value <dbl>

Now, you have three data sets to choose from! Countries, states, or counties. Remember, with the coronavirus data, you have to do some dplyr::summarizing to get it down to countries, though!

Maps to use for this assignment

OK, so, we need world, US state, and US county maps - depending on which of the three datasets you chose

library(sf)

# The world
library(rnaturalearth)
world_map <- ne_countries()

# US States
# install if you don't have USAboundaries loaded
# install.packages("remotes")
# remotes::install_github("ropensci/USAboundaries")
# remotes::install_github("ropensci/USAboundariesData")

library(USAboundaries)
us_states <- us_states()

# US Counties
us_counties <- us_counties() |> janitor::clean_names()

Armed with this, let’s make some maps!

Questions

  1. Which data set - or aspect of a single data set, are you most interested in? Sort through the data sets. What is there? Is it the world? A single country? Multiple countries? All states? Counties in one state?

Filter or summarize your data to just what you are interested in, in terms of space.

For example

library(dplyr)
florida_covid <- covid_counties |>
  filter(stringr::str_detect(location, "[Ff]lorida"))

florida_map <- us_counties |>
  filter(state_name == "Florida")
  1. What type or types of data from that dataset are you interested in? Why? Filter the dataset to that data type only.

  2. What do you want to learn from this slice of the data? Formulate a question and write it out here.

  3. Filter and manipulate the data so that it is in a format to be used to answer the question.

  4. Join the covid data with spatial data to build a map.

  5. Create a map from this data! Make it awesome!

  6. What do you learn from the map you made?

  7. This static map is, I’m sure, great. Load up tmap and make it dynamic! Is there anything different you can learn from this form of visualization?

  8. Last… it’s time to start thinking about your final project. Name the one or more data sources you are interested in exploring. Tell us a bit about what is in them.