本文介绍了如何用R绘制大洲地图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有许多解决方案可以在国家/地区级别上绘制地图,但就我而言,我想在大陆级别上打印统计信息.

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)

推荐答案

rworldmap具有将数据绘制或汇总到包括大陆在内的区域级别的功能.

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')

或者对于7大洲型号:

mapCountryData(sPDF, nameColumnToPlot='REGION')

要将您自己的数据从国家/地区汇总到区域,请查看:

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

?mapByRegion

这篇关于如何用R绘制大洲地图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 21:01