ComenzarEmpieza gratis

Obtaining data for cartography with tigris

Before making your dot-density map of Washington, DC with ggplot2, it will be useful to acquire some ancillary cartographic data with the tigris package that will help map viewers understand what you've visualized. These datasets will include major roads in DC; area water features; and the boundary of the District of Columbia, which you'll use as a background in your map.

Este ejercicio forma parte del curso

Analyzing US Census Data in R

Ver curso

Instrucciones del ejercicio

  • Get a roads dataset for Washington, DC with the roads() function, and filter the result for major roads in the District.
  • Use the area_water() function from tigris to get an area water features dataset.
  • Obtain the boundary of DC by using tigris's counties() function.

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

# Filter the DC roads object for major roads only
dc_roads <- ___("DC", "District of Columbia") %>%
  ___(RTTYP %in% c("I", "S", "U"))

# Get an area water dataset for DC
dc_water <- ___("DC", "District of Columbia")

# Get the boundary of DC
dc_boundary <- ___("DC", cb = TRUE)
Editar y ejecutar código