Exercise 19. Smooth density plot
Now instead of a histogram we are going to make a smooth density plot. In this case, we will not make an object p
. Instead we will render the plot using a single line of code. In the previous exercise, we could have created a histogram using one line of code like this:
heights %>%
ggplot(aes(height)) +
geom_histogram()
Now instead of geom_histogram
we will use geom_density
to create a smooth density plot.
This exercise is part of the course
Data Science Visualization - Module 2
Exercise instructions
Add the appropriate layer to create a smooth density plot of heights.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
## add the correct layer using +
heights %>%
ggplot(aes(height))