Now we are going to change the x-axis to a log scale to account for
the fact the distribution of population is skewed. Let’s start by
defining an object p
holding the plot we have made up to now
p <- murders %>%
ggplot(aes(population, total, label = abb)) +
geom_label(aes(col=region))
1. To change the x-axis to a log scale we learned about the
scale_x_log10()
function. Add this layer to the object p
to change
the scale and render the plot. Store the resulting GGPlot object in p_x_scale
.
2. Repeat the previous exercise but now change both axes to be in the
log scale. Store the resulting GGPlot object in p_xy_scale
.
3. Now edit the code from question 2 to add the title “US Gun Murders in 2010” to the
plot. Save the resulting GGPlot object in p_title
.
Hint: use the ggtitle
function.