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.

  1. First we need a map of USA, I created states.rds and saved it in global.R. It contained variables for long, lat and state names.

  2. 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 and colorNumeric (palette = palette, domain = dt $ hits) to refer to continuous numeric data in an interpolated palette. I have defined list_color for the status mapping andsingle_color for the popup information inglobal.R

  3. 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 the addProviderTiles() function and specify the argument name. You can find out more here https://leaflet-extras.github.io/leaflet-providers/preview/