1. Start a new Rmd document by going to File-->New File-->R Markdown--OK. Save this document under the name yourname_hw5.Rmd. Delete the template Rmarkdown text and chunks (everything starting with ##R Markdown).

  2. Make a new code chunk (CTRL+Alt+I on Windows, Cmd + Option + I on a Mac). In that chuck, load ggplot2, tidyverse, magrittr, and classdata libraries. Please re-install the classdata packages to get the most updated version of the data.

  3. Run the following code chunk to load the covid dataset and to remove any missing observations.

data(covid)
covid<-na.omit(covid)
  1. Start a new code chunk. Use a sequence of functions combined by pipe operators to

    1. Create a new variable, blue that is equal to “Democrat” if a county voted for Hilary and “Republican” otherwise;
    2. Calculate the proportion of new Covid-19 cases per capita by the values of blue and by month (you can do this in one step or in several steps);
    3. Plot the proportion of new cases per population (y-axis) over time (x-axis) by the values of blue. Choose the most appropriate plot type for comparing the proportion of cases in blue and red counties over time. Make your plot look as nice as you can.
  2. What does your plot show?

  3. Use a series of functions combined by pipe operators to:

    1. Subset your data to just Iowa and Illinois;
    2. Calculate the proportion of new Covid-19 cases out of each state’s population by month.
    3. Make a plot that shows cases/cap on the y-axis, month on the x-axisfor each state. Make your plot look as nice as you can.
  4. Interpret the plot in Q6.

  5. Knit the RMarkdown file (press the “Knit” button above) and read through the corresponding html file.

For the submission: submit your solution in an R Markdown file and (just for insurance) submit the corresponding html file with it.