Skip to content

Commit a5e39b5

Browse files
committed
update code for fall 2018
1 parent 2c34805 commit a5e39b5

13 files changed

+50
-36
lines changed

02_choropleth.Rmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Make choropleth by filling county polygons (census geography) with correlated va
6969
nc_pop %>%
7070
st_transform(crs = "+init=epsg:4326") %>%
7171
leaflet(width = "100%") %>%
72-
addProviderTiles(provider = "CartoDB.Positron") %>%
72+
addProviderTiles(provider = "Stamen.TonerLines") %>%
7373
addPolygons(popup = ~ str_extract(NAME, "^([^,]*)"),
7474
stroke = FALSE,
7575
smoothFactor = 0,
@@ -105,7 +105,7 @@ Generate the map with multiple layers.
105105
nc_pop %>%
106106
st_transform(crs = "+init=epsg:4326") %>%
107107
leaflet(width = "100%") %>%
108-
addProviderTiles(provider = "CartoDB.Positron") %>%
108+
addProviderTiles(provider = "Stamen.TonerLines") %>%
109109
addPolygons(popup = ~ str_extract(NAME, "^([^,]*)"),
110110
stroke = FALSE,
111111
smoothFactor = 0,

032_thematic_mapping_geom_sf.Rmd

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,10 @@ BlsWage_ToJoin <- Salary4Helpers %>%
5555

5656
As before, using the `append_data()` function of the `tmaptools` package, append BLS data to the previously loaded shape object
5757

58-
```{}
59-
HelperShapeObject <- append_data(us_geo, BlsWage_ToJoin,
60-
key.shp = "NAME",
61-
key.data = "State")
62-
as_tibble(HelperShapeObject)
58+
``` r
59+
HelperShapeObject <- us_geo %>%
60+
left_join(BlsWage_ToJoin,
61+
by = c("NAME" = "State"))
6362
```
6463

6564

answers-2_tidycensus.Rmd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Make choropleth by filling county polygons (census geography) with correlated va
7676
census_variable %>%
7777
st_transform(crs = "+init=epsg:4326") %>%
7878
leaflet(width = "100%") %>%
79-
addProviderTiles(provider = "CartoDB.Positron") %>%
79+
addProviderTiles(provider = "Stamen.TonerLines") %>%
8080
addPolygons(popup = ~ str_extract(NAME, "^([^,]*)"),
8181
stroke = FALSE,
8282
smoothFactor = 0,
@@ -130,7 +130,7 @@ MapPalette <- colorBin(palette = "viridis",
130130
census_variable %>%
131131
st_transform(crs = "+init=epsg:4326") %>%
132132
leaflet(width = "100%") %>%
133-
addProviderTiles(provider = "CartoDB.Positron") %>%
133+
addProviderTiles(provider = "Stamen.TonerLines") %>%
134134
addPolygons(popup = ~ str_extract(NAME, "^([^,]*)"),
135135
stroke = FALSE,
136136
smoothFactor = 0,
@@ -170,7 +170,7 @@ MapPalette <- colorNumeric(palette = "viridis",
170170
census_variable %>%
171171
st_transform(crs = "+init=epsg:4326") %>%
172172
leaflet(width = "100%") %>%
173-
addProviderTiles(provider = "CartoDB.Positron") %>%
173+
addProviderTiles(provider = "Stamen.TonerLines") %>%
174174
addPolygons(popup = ~ str_extract(NAME, "^([^,]*)"),
175175
stroke = FALSE,
176176
smoothFactor = 0,

docs/01_georeference.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

docs/02_choropleth.html

Lines changed: 6 additions & 6 deletions
Large diffs are not rendered by default.

docs/032_thematic_mapping_geom_sf.html

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -456,10 +456,9 @@ <h2>Wrangle the data</h2>
456456
<div id="append-data" class="section level2">
457457
<h2>Append data</h2>
458458
<p>As before, using the <code>append_data()</code> function of the <code>tmaptools</code> package, append BLS data to the previously loaded shape object</p>
459-
<pre><code>HelperShapeObject &lt;- append_data(us_geo, BlsWage_ToJoin,
460-
key.shp = &quot;NAME&quot;,
461-
key.data = &quot;State&quot;)
462-
as_tibble(HelperShapeObject)</code></pre>
459+
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">HelperShapeObject &lt;-<span class="st"> </span>us_geo <span class="op">%&gt;%</span><span class="st"> </span>
460+
<span class="st"> </span><span class="kw">left_join</span>(BlsWage_ToJoin,
461+
<span class="dt">by =</span> <span class="kw">c</span>(<span class="st">&quot;NAME&quot;</span> =<span class="st"> &quot;State&quot;</span>))</code></pre></div>
463462
</div>
464463
<div id="contiguous-48-states" class="section level2">
465464
<h2>Contiguous 48 states</h2>

docs/033_thematic_leaflet_example.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

docs/answers-1_xy-leaflet.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,8 @@ <h3>Plot XY on the Map</h3>
338338
<span class="st"> </span><span class="kw">addMarkers</span>(<span class="dt">lat =</span> <span class="op">~</span>Latitude,
339339
<span class="dt">lng =</span> <span class="op">~</span>Longitude,
340340
<span class="dt">popup =</span> xy_locations<span class="op">$</span>Company)</code></pre></div>
341-
<div id="htmlwidget-17fee30cfc27e6cc0fda" style="width:100%;height:480px;" class="leaflet html-widget"></div>
342-
<script type="application/json" data-for="htmlwidget-17fee30cfc27e6cc0fda">{"x":{"options":{"crs":{"crsClass":"L.CRS.EPSG3857","code":null,"proj4def":null,"projectedBounds":null,"options":{}}},"calls":[{"method":"addTiles","args":["//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",null,null,{"minZoom":0,"maxZoom":18,"tileSize":256,"subdomains":"abc","errorTileUrl":"","tms":false,"noWrap":false,"zoomOffset":0,"zoomReverse":false,"opacity":1,"zIndex":1,"detectRetina":false,"attribution":"&copy; <a href=\"http://openstreetmap.org\">OpenStreetMap<\/a> contributors, <a href=\"http://creativecommons.org/licenses/by-sa/2.0/\">CC-BY-SA<\/a>"}]},{"method":"addMarkers","args":[[40.2487413,-7.9110809,9.49858,-7.0320658,-17.0490108,21.8693003,53.3323703,31.394935,30.274084,14.1313261],[72.1297653,111.4253892,50.8105261,108.4365067,-41.5612423,106.7691712,-6.2152673,92.835795,120.15507,122.8277624],null,null,null,{"interactive":true,"draggable":false,"keyboard":true,"title":"","alt":"","zIndexOffset":0,"opacity":1,"riseOnHover":false,"riseOffset":250},["Ailane","Thoughtbeat","Lazz","Zoomdog","Minyx","Devpulse","Meembee","Quamba","Realcube","Fatz"],null,null,null,null,{"interactive":false,"permanent":false,"direction":"auto","opacity":1,"offset":[0,0],"textsize":"10px","textOnly":false,"className":"","sticky":true},null]}],"limits":{"lat":[-17.0490108,53.3323703],"lng":[-41.5612423,122.8277624]}},"evals":[],"jsHooks":[]}</script>
341+
<div id="htmlwidget-58e7bf340d6667624cf3" style="width:100%;height:480px;" class="leaflet html-widget"></div>
342+
<script type="application/json" data-for="htmlwidget-58e7bf340d6667624cf3">{"x":{"options":{"crs":{"crsClass":"L.CRS.EPSG3857","code":null,"proj4def":null,"projectedBounds":null,"options":{}}},"calls":[{"method":"addTiles","args":["//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",null,null,{"minZoom":0,"maxZoom":18,"tileSize":256,"subdomains":"abc","errorTileUrl":"","tms":false,"noWrap":false,"zoomOffset":0,"zoomReverse":false,"opacity":1,"zIndex":1,"detectRetina":false,"attribution":"&copy; <a href=\"http://openstreetmap.org\">OpenStreetMap<\/a> contributors, <a href=\"http://creativecommons.org/licenses/by-sa/2.0/\">CC-BY-SA<\/a>"}]},{"method":"addMarkers","args":[[40.2487413,-7.9110809,9.49858,-7.0320658,-17.0490108,21.8693003,53.3323703,31.394935,30.274084,14.1313261],[72.1297653,111.4253892,50.8105261,108.4365067,-41.5612423,106.7691712,-6.2152673,92.835795,120.15507,122.8277624],null,null,null,{"interactive":true,"draggable":false,"keyboard":true,"title":"","alt":"","zIndexOffset":0,"opacity":1,"riseOnHover":false,"riseOffset":250},["Ailane","Thoughtbeat","Lazz","Zoomdog","Minyx","Devpulse","Meembee","Quamba","Realcube","Fatz"],null,null,null,null,{"interactive":false,"permanent":false,"direction":"auto","opacity":1,"offset":[0,0],"textsize":"10px","textOnly":false,"className":"","sticky":true},null]}],"limits":{"lat":[-17.0490108,53.3323703],"lng":[-41.5612423,122.8277624]}},"evals":[],"jsHooks":[]}</script>
343343
</div>
344344
</div>
345345

docs/answers-2_tidycensus.html

Lines changed: 9 additions & 9 deletions
Large diffs are not rendered by default.

docs/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,8 @@
274274

275275

276276
<p> </p>
277+
<p><a href="slides"><strong>Slides</strong></a></p>
278+
<p><a href="https://github.com/libjohn/map-fall2018">Code for Hands-on Workshop – Fall 2018</a></p>
277279
<div id="overview" class="section level2">
278280
<h2>Overview</h2>
279281
<p>These learning and quick-reference resource pages support the face-to-face workshop, <em>Mapping with R</em>, offered via the <a href="https://library.duke.edu/data/">Data &amp; Visualization Services</a> Department, Duke University Libraries. The exercises and workshop are designed to help you learn georeferencing, make a <a href="https://en.wikipedia.org/wiki/Choropleth_map">choropleth</a> with USA census data via the <a href="https://walkerke.github.io/tidycensus/">tidycensus</a> package, and briefly introducing the <a href="http://r-spatial.github.io/sf/">simple features for R</a> package. The introduction of these very useful R packages and some very basic concepts will give you enough information to make your own customized thematic maps.</p>

0 commit comments

Comments
 (0)