Session Ready
Exercise

Exercise 4 - Stratify by State

Repeat the previous exercise, but instead of pollster, stratify by state. Here we can't show grades.

Instructions
100 XP
  • Create an object called p_hits that contains the proportion of intervals that contain the actual spread using the following steps.
  • Use the mutate function to create a new variable called hit that contains a logical vector for whether the actual_spread falls between the lower and upper confidence intervals.
  • Use the group_by function to group the data by state.
  • Use the filter function to filter for states that have more than 5 polls.
  • Summarize the proportion of values in hit that are true as a variable called proportion_hits. Also create new variables for the number of polls in each state using the n() function.
  • Use the arrange function to arrange the proportion_hits in descending order.