prob2
根据我的变量值,我想用 UE 的一些国家填充地图,然后是亚洲和非洲等一些大陆。这是我的数据map_d
:
state prob2
<chr> <dbl>
Germany 0.6
Austria 2.9
Belgium 1.9
Bulgaria 0.6
Cyprus 0.0
Croatia 1.7
...
Other Asian 9.2
Other African 2.5
Other North American 10.7
Other Latin American 2.3
Other Oceania 5.0
首先,我使用以下代码填写欧洲国家:
europ_map <- map_data("world", region = c(
"Germany",
"Austria",
"Belgium",
"Bulgaria",
"Chipre",
"Croacia",
"Denmark",
"Slovakia",
"Slovenia",
"Spain",
"Estonia",
"Finland",
"France",
"Greece",
"Hungary",
"Ireland",
"Italy",
"Latvia",
"Lithuania",
"Luxembourg",
"Malta",
"Norway",
"Netherlands",
"Poland",
"Portugal",
"UK",
"Czech Republic",
"Romania",
"Sweden"))
fin_map <- merge(europ_map, map_d, by.x="region", by.y="state")
library(plyr)
fin_map <- arrange(fin_map, group, order)
ggplot(fin_map, aes(x=long, y=lat, group=group, fill=prob2)) +
geom_polygon(colour = "white") +
coord_map("polyconic")
产生这张地图的: 欧洲地图
现在,我需要在我的地图中添加大陆的形状,并填充prob2
. 有可能吗?
我在这篇文章中发现了如何绘制大陆,但这是一种不同的方法:David Ameller 的问题,并且我无法通过这段代码添加变量值。
提前致谢!!