From the course: Creating Maps with R
Unlock the full course today
Join today to access over 24,200 courses taught by industry experts.
ggplot2 choropleth and discrete data
From the course: Creating Maps with R
ggplot2 choropleth and discrete data
- [Instructor] We're going to use ggplot2 to create a choropleth of a discrete variable, specifically the most popular pets that aren't cats or dogs in each of the states in a contiguous United States. To start this map, I'd like you to open the script in the 04_03b project. And let's go through the code. We're going to load our packages on lines 1 through 5, line 7 through 8, we'll read in our dataset, lines 10 through 15, we're going to filter for the contiguous United States of America, and finally on line 17 through 19, we're going to join our two datasets together into one SF object. I'm also providing custom colors for each of the pets, which I define on lines 21 through 28. Let's give ourselves some space with some new lines. And I'll scroll down. And let's start our map off with the function ggplot. And we'll add a geom_sf layer, with the argument data is equal to US most popular pets. And that's the start of…
Contents
-
-
-
-
-
-
Use geom_sf to visualize geo locations5m 53s
-
(Locked)
ggplot2 choropleth and continuous data6m 46s
-
(Locked)
ggplot2 choropleth and discrete data6m 14s
-
(Locked)
Label maps with ggrepel package5m 14s
-
(Locked)
Zoom into regions with coords_sf()3m 37s
-
(Locked)
Transform CRS with coord_sf()2m 25s
-
(Locked)
Challenge: Label a geobubble chart of Germany's biggest cities32s
-
(Locked)
Solution: Label a geobubble chart of Germany's biggest cities4m 45s
-
(Locked)
Challenge: Visualize state coastline length with choropleth33s
-
(Locked)
Solution: Visualize state coastline length with choropleth4m 11s
-
-
-
-