LoslegenKostenlos loslegen

addPolygons() Function

Let's look at those zip codes with missing data to hypothesize why they do not have income data.

We are mapping ZCTAs (not actual zip codes) so not every part of NC will have a boundary. Our boundaries may overlap because the file was simplified to reduce size. These are trade offs to consider when mapping polygons.

Enough nuance, let's make a map. You can pipe the shp data directly into our calls to leaflet(), addTiles(), and addPolygons() without supplying any additional arguments to map North Carolina's zip codes. To get you started, the shp SpatialPolygonsDataFrame including the IRS income variables has been loaded for you.

Diese Übung ist Teil des Kurses

Interactive Maps with leaflet in R

Kurs anzeigen

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# map the polygons in shp
___ %>% 
    leaflet() %>% 
    addTiles() %>% 
    ___()
Code bearbeiten und ausführen