From the course: Creating Maps with R

Unlock the full course today

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

Label maps with ggrepel package

Label maps with ggrepel package

From the course: Creating Maps with R

Label maps with ggrepel package

- [Instructor] The ggrepel package is an awesome extension for labeling ggplot2 charts. Unfortunately it doesn't yet work with sf objects. So if we want to label our maps, we need to do a little bit of work to convert sf objects into data frames or tibbles. To demonstrate how this works, we're going to add labels to this Geo bubble chart of the larger cities in Brazil. I'd like you to load the script in the 04_04b project, and let's start running the code. So lines 14 through one we're going to load our packages and define our data sets and then I'll make the environment smaller, so we can see our data visualization code on lines 19 through 37. So that's our geo bubble chart that we're going to add our labels too. The first thing we need to do is load the ggrepel package. So I'll scroll the top of the script once more. I'll type library ggrepel, and I'll run that code to load the package. Now I'm going to introduce you…

Contents