Adding geometries
The diamonds
dataset contains details of 1,000 diamonds. Among the variables included are carat
(a measurement of the diamond's size) and price
.
You'll use two common geom layer functions:
geom_point()
adds points (as in a scatter plot).geom_smooth()
adds a smooth trend curve.
As you saw previously, these are added using the +
operator.
ggplot(data, aes(x, y)) +
geom_*()
Where *
is the specific geometry needed.
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.
# Explore the diamonds data frame with str()
___