From the course: Creating Maps with R

Unlock the full course today

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

Leaflet choropleth and discontinuous data

Leaflet choropleth and discontinuous data

From the course: Creating Maps with R

Leaflet choropleth and discontinuous data

- Let's use Leaflet to create choropleth of discreet variables using the script in the O-5-O-5-B project. Let's start by running the script from lines 20 through to 1. So that's going to load our packages. It's going to obtain ship files for the contiguous United States and it's going to join those together on line 18 through 20. Then lines 22 through 29, I'm defining a custom color palette using a named vector and lines 31 through 33 I've started off our choropleth. So if I run that code we get the outline of the contiguous United States. Now I'm going to improve this map right away by changing the width of the lines. So I'll add weight is equal to one and now I need to create a fill pallet for my choropleth. So I'll add a couple of new lines here and let's create my pallet. So I'll call it pal popular pet and I'll use the function color factor. Color factor allows us to provide named palettes. And it also…

Contents