Creating graphs with regional maps
In this recipe, we will learn how to plot data on regional maps within individual countries rather than the whole world map. We will look at examples based on the United States and European countries.
Getting ready
Just as with the previous recipe, we will make use of the maps
package to draw the map and the RColorBrewer
package to choose color schemes. So, let's make sure that they are loaded:
library(maps) library(RColorBrewer)
We will use the inbuilt USArrests
example dataset, which contains crime statistics, in arrests per 100,000 residents for assault, murder, and rape in each of the 50 US states in 1973.
How to do it...
Let's plot the arrests rate for murders in US states in 1973. The default graphics device ...
Get R: Data Analysis and Visualization now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.