Exercise: Visualize the “cars” dataset

Create a scatter plot using ggplot() and visualize the cars dataset with the car’s stopping distance dist on the x-axis and the speed of the car on the y-axis.

The ggplot2 package is already loaded. Follow these steps to create the plot:

  1. Specify the dataset through the ggplot() function
  2. Specify a geometric point layer with the geom_point() function
  3. Map the speed to the x-axis and the dist to the y-axis with aes()
Output

Submit code to see output here.

Create a scatter plot with ggplot