Session Ready
Exercise

Scatterplots

We made a plot of total murders versus population and noted a strong relationship: not surprisingly states with larger populations had more murders. You can run the code in the console to get the plot.

library(dslabs)
data(murders)

population_in_millions <- murders$population/10^6
total_gun_murders <- murders$total

plot(population_in_millions, total_gun_murders)

Note that many states have populations below 5 million and are bunched up in the plot. We may gain further insights from making this plot in the log scale.

Instructions
100 XP
  • Transform the variables using the log base 10 transformation
  • Plot the log transformed total murders versus population