1. Learn
  2. /
  3. Courses
  4. /
  5. HarvardX Data Science Module 4 - Inference and Modeling

Exercise

Exercise 10 - Filter Error Plot

Some of these states only have a few polls. Repeat the previous exercise to plot the errors for each state, but only include states with five good polls or more.

Instructions

100 XP
  • Use the filter function to filter the data for polls with grades equal to A+, A, A-, or B+.
  • Group the filtered data by state using group_by.
  • Use the filter function to filter the data for states with at least 5 polls. Then, use ungroup so that polls are no longer grouped by state.
  • Use the reorder function to order the state data by error.
  • Using ggplot, set the aesthetic with state as the x-variable and error as the y-variable.
  • Use geom_boxplot to indicate that we want to plot a boxplot.
  • Use geom_point to add data points as a layer.