How can I plot a continents map with R?

前端 未结 3 1053
傲寒
傲寒 2021-01-04 14:34

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 us

3条回答
  •  迷失自我
    2021-01-04 14:43

    rworldmap has functions for plotting or aggregating data to regional levels including continents.

    A simple start that should produce the plot below :

    library(rworldmap)
    #get coarse resolution world from rworldmap
    sPDF <- getMap()  
    #mapCountries using the 'continent' attribute  
    mapCountryData(sPDF, nameColumnToPlot='continent')
    

    Or for the 7 continents model :

    mapCountryData(sPDF, nameColumnToPlot='REGION')
    

    To aggregate your own data from country to regional level look at :

    ?mapByRegion
    

    rworldmap continent map

提交回复
热议问题