New ggplot2 Answer Checker and Updates to ggplot2 Syntax!

We are excited to announce new and improved answer checking for ggplot2 plots in R! Our new answer checker provides custom feedback whenever a ggplot is different from the correct answer. Now it will be much easier to figure out what parts of the ggplot() call need to be changed to get the correct answer!

Here’s an example from screen 273.6. This is the correct answer:

ggplot(data = life_expec, 
  aes(x = Year, y = Avg_Life_Expec)) +
  geom_line()

But what if we accidentally specify an incorrect column for the x-axis, like this?

ggplot(data = life_expec, 
  aes(x = Avg_Life_Expec, y = Avg_Life_Expec)) +
  geom_line()

Now we will see this custom error message:

The x-axis input is incorrect in your plot

This custom answer checker is now in use for almost all ggplot screens across the Dataquest R path.

We have also updated the ggplot2 syntax that we teach to match the conventional syntax used for ggplots. From now on, you will see the aes() function nested within the ggplot() call, like this:

ggplot(data = life_expec, 
  aes(x = Year, y = Avg_Life_Expec)) +
  geom_line()

We’ve upgraded our content and answer code to teach this convention for all ggplot2 screens on the platform. If you prefer to follow the syntax structure that we used to teach on Dataquest, no problem! Our answer checker is now more flexible and allows for this!

Do you have any questions or feedback? Please post it here! We hope that this improves the ggplot2 learning experience!

Happy plotting!

-Casey
R Content Author at Dataquest

3 Likes