Exercise

Exercise 6. Pollster results for d

Create a new object called pollster_results that contains the pollster's name, the end date of the poll, the difference in the proportion of voters who declared a vote either, and the lower and upper bounds of the confidence interval for the estimate.

Instructions

100 XP
  • Use the mutate function to define four new columns: 'X_hat', 'se_hat', 'lower', and 'upper'. Temporarily add these columns to the polls object that has already been loaded for you.
  • In the X_hat column, calculate the proportion of voters for Clinton using d_hat.
  • In the se_hat column, calculate the standard error of the spread for each poll using the sqrt function.
  • In the lower column, calculate the lower bound of the 95% confidence interval using the qnorm function.
  • In the upper column, calculate the upper bound of the 95% confidence interval using the qnorm function.
  • Use the select function to select the pollster, enddate, d_hat, lower, upper columns from polls to save to the new object pollster_results.