In this recipe, you will learn how to plot data on maps.
In order to plot maps in R, we need to install the maps library. Here's how to do it:
install.packages("maps")
When you run the preceding command, you will most likely be prompted by R to choose from a list of locations where you can download the library. For example, if you are based in the UK, you can choose either the UK (Bristol) or UK (London) options.
Once the library is installed, we must load it using the library()
command:
library(maps)
We can make a simple world map with just one command:
map()
map('world', fill = TRUE,col=heat.colors(10))