Exercise

Exercise 9- Plot Bias by State

We see that, at the state level, the median error was slightly in favor of Clinton. The distribution is not centered at 0, but at 0.037. This value represents the general bias we described in an earlier section.

Create a boxplot to examine if the bias was general to all states or if it affected some states differently. Filter the data to include only pollsters with grades B+ or higher.

Instructions

100 XP
  • Use the filter function to filter the data for polls with grades equal to A+, A, A-, or B+.
  • 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.