Saving plots as variables
Plots can be saved as variables, which can be added to later on using the +
operator. This is really useful if you want to make multiple related plots from a common base.
This exercise is part of the course
Introduction to Data Visualization with ggplot2
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Draw a ggplot
plt_price_vs_carat <- ___(
# Use the diamonds dataset
___,
# For the aesthetics, map x to carat and y to price
___(___, ___)
)
# Add a point layer to plt_price_vs_carat
___ + ___