Build the kind of plot Scatterplots in ggplot2 describes, and read a number off the model behind it.

The program reads an iris species: setosa, versicolor or virginica.

  1. Keep only the rows of iris for that species.
  2. With ggplot2, draw Petal.Width against Petal.Length as points, add a straight trend line with geom_smooth(method = "lm", formula = y ~ x), and title it with the species.
  3. Fit the same line with lm(Petal.Width ~ Petal.Length, data = ...) and print its slope rounded to 3 decimal places, as Slope: …

For which species does petal width rise fastest with length? Does the grey band around the line agree with how scattered the points look?

Run draws your plot under the output. Check and Submit test the numbers your program prints.

You do not have permission to attempt this activity.