Graduated symbol maps
There are many other effective ways to map statistical data besides choropleth maps. One such example is the graduated symbol map, which represents statistical variation by differently-sized symbols. In this exercise, you'll learn how to use the st_centroid()
tool in the sf package to create points at the center of each state to be used as inputs to a graduated symbol map in ggplot2.
This exercise is part of the course
Analyzing US Census Data in R
Exercise instructions
- Use the
st_centroid()
function to generate point centers for each US state. - When plotting the centers, set the
size
parameter toestimate
to scale the point sizes. - Use the
scale_size_continuous()
function to adjust the range of sizes on the map.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
library(sf)
# Generate point centers
centers <- ___(state_value)
# Set size parameter and the size range
___() +
___(data = state_value, fill = "white") +
___(data = centers, aes(___ = estimate), shape = 21,
fill = "lightblue", alpha = 0.7, show.legend = "point") +
___(range = c(1, 20))