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.
Este exercício faz parte do curso
Analyzing US Census Data in R
Instruções do exercício
- Use the
st_centroid()function to generate point centers for each US state. - When plotting the centers, set the
sizeparameter toestimateto scale the point sizes. - Use the
scale_size_continuous()function to adjust the range of sizes on the map.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
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))