Submission Details

Due date: This homework is for 15 points of extra credit to be added to the midterm exam points and is due before class on Thursday.

Submission process: submit both the R Markdown file and the corresponding html file on canvas. Please submit both the .Rmd and the .html files separately and do not zip the two files together.


Measles Vaccination Rates

  1. Download the RMarkdown file with these homework instructions to use as a template for your work. Make sure to replace “Your Name” in the YAML with your name.

  2. This week we will return to the measles data from homework 7.

library(tidyverse)
measles <- read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-02-25/measles.csv')
  1. Data clean up:
## your answer here
  1. Load the county map data using the function map_data() and save as us_counties.
## your answer here
  1. Additional data cleaning and data joining:
## your answer here
  1. Draw a map of the us counties and map the variable threshold to fill. Set the outline of the counties to the color “#f4f4f8” and a size of 0.1. Apply the palette “Dark2” from RColorBrewer, name the scale “Rate > 95%”, and set an na.value of “grey80”. Apply the theme theme_minimal().
## your answer here
  1. Use geom_polygon()to draw a map of the counties (don’t use the measles_one data yet). Apply the following parameters (outside of aes()): fill = "#f5f5f2", color = "black", and size = 0.1. Save this plot as plot1 and print.
## your answer here
  1. Now we want to add on the measles_one data. Start with plot1 and add an additional layer of points using the measles_one data created in question 3 with the points colored according the variable rate. Add an alpha of 0.5 and size of 0.5. Save this plot as plot2 and print.
## your answer here
  1. Now we will add some labels. Start with plot2 and add the title "Schools' Vaccination Rate in 31 U.S. States" and the caption "Overall vaccination rate shown in \nFL, ID, IA, MI, NJ, NC, OK, RI, TN, WI. Elsewhere, the \nMeasles, Mumps, and Rubella (MMR) vaccination rate is shown.". Save this plot as plot3 and print.
## your answer here
  1. Now we will modify the color scale. Add the color scale scale_color_viridis_c() with palette “plasma”. Name the scale “Vaccination rate”, reverse the direction (direction = -1), and add the argument guide = guide_legend(direction = "horizontal", title.position = "top", title.hjust = 0.5). Save this plot as plot4 and print.
## your answer here
  1. The final step is to customize the theme. Let’s first start with a blank slate by applying theme_void() to plot4. Next, add the following theme components with the function theme() and print your final map.
## your answer here