我目前使用
制作了英国地图library(maps)
UK <- map_data("world") %>%
filter(region == "UK")
但我如何过滤掉英格兰,苏格兰和威尔士并离开北爱尔兰?我曾尝试将该地区改为北爱尔兰,但它不承认它。
非常感谢任何帮助
答案 0 :(得分:2)
有一个subregion
列。
unique(UK$subregion)
# [1] "Isle of Wight" "Wales" "Northern Ireland" "Scotland" "Great Britain"
如果您只想要北爱尔兰,您可以将代码调整为......
NI <- map_data("world") %>%
filter(region == "UK" & subregion == "Northern Ireland")
head(NI)
# long lat group order region subregion
# 1 -6.218018 54.08872 572 40086 UK Northern Ireland
# 2 -6.303662 54.09487 572 40087 UK Northern Ireland
# 3 -6.363672 54.07710 572 40088 UK Northern Ireland
# 4 -6.402588 54.06064 572 40089 UK Northern Ireland
# 5 -6.440284 54.06363 572 40090 UK Northern Ireland
# 6 -6.548145 54.05728 572 40091 UK Northern Ireland
然后是基本情节...
ggplot(NI, aes(x = long, y = lat)) +
geom_polygon() +
coord_map() +
ggthemes::theme_map()
生产......