13.3 Compared breakdown by Region
There are several steps to create a map of the United States that will be used to compare keyword objects by region.
First we need a map of USA, I created
states.rds
and saved it inglobal.R
. It contained variables for long, lat and state names.We need to fill in the color by state. I mentioned in the chapter 12.2.2. I chose blue for Amazon, orange for Wal-Mart, green for the Best buy, and purple for the Target. I used
brewer.pal (8, color)
to generate the flavor color andcolorNumeric (palette = palette, domain = dt $ hits)
to refer to continuous numeric data in an interpolated palette. I have definedlist_color
for the status mapping andsingle_color
for thepopup
information inglobal.R
Leaflet provided a function to add tiles is by calling
addTiles()
with no arguments; By default, OpenStreetMap tiles are used. Leaflet also provides a named list of all third party tile providers supported by the plugin, just call theaddProviderTiles()
function and specify the argument name. You can find out more here https://leaflet-extras.github.io/leaflet-providers/preview/