Mathematics Homework Help

Mathematics Homework Help. Rstudio problem

Please help me with my homework problem by using dplyr function and mutate() knowladge. Here are the questrions and data

library(dplyr)
library(ggplot2)
library(readr)
measles <- read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-02-25/measles.csv')
  1. Use dplyr functions to:
  • only include observations with enrollment greater than 0 and exclude the school “West Valley School Prek-6” (there is an issue with that observation)
  • filter for rows that have a unique combination of the variables year, city, state, name, type, enroll, and mmr (there are duplicates in the data)
  • Inside mutate() use weighted.mean() to calculate the mean MMR vaccination rates weighted by the enrollment. Name this new variable state_avg.
  • For each city and state combination, calculate the mean MMR vaccination rate weighted by enrollment, the total number of students enrolled, and the mean of the state average calculated in the previous step.
  • only consider rows where the total enrollment is more than 250 and less than 100,000.

2.Now use the previous data set to draw a scatter plot with the mean MMR rate for each city on the y-axis and the student enrollment on the x-axis and color by the state mean MMR rate. Use the code below as your starting point and add in the necessary aesthetic mappings within ggplot(aes( )). Describe and summarise the chart.

question6_data %>%
  ggplot(aes( )) + 
  geom_hline(yintercept = 95, linetype = "dashed", size = 0.25, color = "grey40") +
  geom_point(size = 2, alpha = .3) +
  scale_color_gradient(low = "red", high = "blue", limits=c(88, 96), oob = scales::squish, 
  guide = guide_colorbar(direction = "horizontal", title.position = "top", 
                        title = "State average immunization rate", barwidth = 15, barheight = 0.25, 
                        ticks = FALSE, title.hjust = 0.5)) +
  theme_minimal() +
  theme(legend.position = "bottom") +
  ggtitle("MMR immunization rates at schools grouped across US cities") +
  labs(subtitle="According to data collected by The Wall Street Journal",
       x = "Student Enrollment", y = "") +
  scale_x_continuous(labels = scales::comma) 

Mathematics Homework Help