There are many solutions to plot maps at country level, but in my case I want to print statistics at continent level.
The only thing that comes into my mind is to use the country level maps and use a list of countries for each continent, but I was wondering if there is any simple solution for this kind of maps. To implement my idea it would be like this:
## produce the world map
map()
## list of countries per continent
SA <- c("argentina", "bolivia", "brazil", "chile", "colombia", "ecuador", "guyana", "paraguay", "peru", "suriname", "uruguay", "venezuela")
map(regions = SA, fill=TRUE, add=TRUE)
To create a world map using it we will use the geom_map() function of the ggplot2 package of the R Language. This function returns a ggplot object so all the functions that work on other ggplot plots will be working in geom_map() too. where, data: determines the data be displayed in this layer.
library(sp) #Load your libraries
library(maptools)
#Download the continents shapefile
download.file("http://baruch.cuny.edu/geoportal/data/esri/world/continent.zip",
"cont.zip")
#Unzip it
unzip("cont.zip")
#Load it
cont <- readShapeSpatial("continent.shp")
#Plot it
plot(cont,
col=c("white","black","grey50","red","blue","orange","green","yellow"))
#Or any other combination of 8 colors
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With