IniziaInizia gratis

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.

Questo esercizio fa parte del corso

Analyzing US Census Data in R

Visualizza il corso

Istruzioni dell'esercizio

  • Use the st_centroid() function to generate point centers for each US state.
  • When plotting the centers, set the size parameter to estimate to scale the point sizes.
  • Use the scale_size_continuous() function to adjust the range of sizes on the map.

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

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))
Modifica ed esegui il codice