To create a map in R, we can use the leaflet
package which allows us to create interactive and customizable maps. Here's an example code to create a map of the United States with state borders:
main.r405 chars14 lines
This code first reads the state borders from a GeoJSON file and creates a list. Then we create a leaflet
map centered at the US with an initial zoom level. We add a tile layer from CartoDB.Positron
to give a nice background to the map. Finally, we add the state borders using the addPolygons
function.
You can customize the map by changing the zoom level, the tile layer, and the colors of the polygons. The leaflet
package offers many options for creating interactive and dynamic maps in R.
gistlibby LogSnag