r4ds-exercise-solutions icon indicating copy to clipboard operation
r4ds-exercise-solutions copied to clipboard

Wrong axis order in Exercise 3.2.5

Open persep opened this issue 3 years ago • 0 comments

Exercise 3.2.5 on page https://jrnold.github.io/r4ds-exercise-solutions/data-visualisation.html asks

What happens if you make a scatter plot of class vs drv? Why is the plot not useful?

The proposed solution you give to make the plot is:

ggplot(mpg, aes(x = class, y = drv)) +
  geom_point()

But the correct solution is to plot the axis as "y-axis variable vs. x-axis variable." so it should be:

ggplot(mpg, aes(x = drv, y = class)) +
  geom_point()

persep avatar Feb 24 '21 10:02 persep