gpt4 book ai didi

r - 如何使用 R 绘制大陆 map ?

转载 作者:行者123 更新时间:2023-12-04 04:53:24 25 4
gpt4 key购买 nike

在国家级别绘制 map 有很多解决方案,但就我而言,我想在大陆级别打印统计数据。

我唯一想到的是使用国家级 map 并使用每个大陆的国家列表,但我想知道这种 map 是否有任何简单的解决方案。为了实现我的想法,它会是这样的:

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

worldmap

最佳答案

rworldmap具有将数据绘制或聚合到区域级别(包括大陆)的功能。

一个简单的开始,应该产生下面的情节:

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

或者对于 7 大洲模型:
mapCountryData(sPDF, nameColumnToPlot='REGION')

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

rworldmap continent map

关于r - 如何使用 R 绘制大陆 map ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20146809/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com