From the course: Creating Maps with R

Unlock the full course today

Join today to access over 24,200 courses taught by industry experts.

Solution: Add pop-up labels to a map of German cities

Solution: Add pop-up labels to a map of German cities

From the course: Creating Maps with R

Solution: Add pop-up labels to a map of German cities

(upbeat music) - Let's start solving this challenge by opening the popup geoscatter dot R script in the 05_08b project. And let's run the code from line 15 through to 1. So that's going to load our packages and define our two data sets. And I've started off our map on line 17 through 24. So this is already a geoscatter plot. The first thing that I want to do is I want to modify the fill color of each of the cities dependent on whether it's the capital or not. Let's print germany_cities to the console so we can see what we're dealing with. And we've got a column capital with either one or zero. It's quite hard to customize how this appears in the leaflet map itself. It's much easier to wrangle our code first. So let's go here and add a few lines and I'm going to take germany_cities. I'll pipe it into the function mutate and we'll create a new column called city_type which is what we'll use to change the fill of our…

Contents