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.
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.
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')
state, name, county, overall, mmr, lat, lng, and enroll.lng < 0).mmr >= 0 or overall >= 0.ifelse(), create a new variable rate where the value is equal to the value of mmr when mmr >= 0 is true and equal to overall when mmr >= 0 is false.measles_new## your answer here
map_data() and save as us_counties.## your answer here
measle_one data created in question 3.str_to_lower() from the stringr package, to create a variable subregion that is the lowercase version of county.str_to_lower() from the stringr package, to create a variable region that is the lowercase version of state.region - subregion pair, use summarise() to calculate the mean of the variable rate.threshold that is TRUE when rate > 0 and FALSE otherwise.full_join() to join in the us_counties data by region and subregion.measles_two.## your answer here
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
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
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
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
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
theme_void() to plot4. Next, add the following theme components with the function theme() and print your final map.hjust and vjust of 0.5.hjust of 0.5.fill = "#f5f5f2" and color = NA.plot.margin = margin(t = 1, r = 1, b = 1, l = 1, unit = "cm").legend.margin = margin(t = 2, r = 2, b = 5, l = 2, unit = "mm").## your answer here