最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

R語言空間可視化:繪制英國脫歐投票地圖

2021-04-02 09:22 作者:拓端tecdat  | 我要投稿

原文鏈接:http://tecdat.cn/?p=13247

本文我們繪制英國脫歐投票的地圖。第一步是繪制底圖

  1. library(sp)

  2. library(raster)

  3. download.file("http://biogeo.ucdavis.edu/data/gadm2.8/rds/GBR_adm2.rds","GBR_adm2.rds")

  4. UK=readRDS("GBR_adm2.rds")

  5. UK@data[159,"HASC_2"]="GB.NR"

  6. plot(UK, xlim = c(-4,-2), ylim = c(50, 59), main="UK areas")

添加愛爾蘭

?


  1. plot(IRL,add=TRUE)

?

?添加法國,它位于右下方,因此我們應(yīng)該看到一點(diǎn)…


  1. plot(FR,add=TRUE)

?

?

然后,我們可以檢索英國退歐公投數(shù)據(jù)


  1. referendum=ddply(referendum,.(Region,HASC_code),summarise,Remain=sum(Remain),Leave=sum(Leave))

我們可以發(fā)現(xiàn),脫歐贏得了51.89%的選票

  1. > sum(referendum$Leave)/(sum(referendum$Leave)+sum(referendum$Remain))

  2. [1] 0.5189184

大家可以看一下,使用


  1. plot(UK, col = map_data$Brexit, border = "gray1", xlim = c(-4,-2), ylim = c(50, 59), main="How the UK has voted?", bg="#A6CAE0")

  2. plot(IRL, col = "lightgrey", border = "gray1",add=TRUE)

  3. plot(FR, col = "lightgrey", border = "gray1",add=TRUE)

(我們添加了一個小圖例以使其更清晰)。為此,我們可以使用制圖軟件包

  1. plot(UK, col = "grey", border = "gray1", xlim = c(-4,-2), ylim = c(50, 59),bg="#A6CAE0")

  2. plot(IRL, col = "lightgrey", border = "gray1",add=TRUE)

  3. plot(FR, col = "lightgrey", border = "gray1",add=TRUE)

  4. choroLayer(spdf = UK,

  5. df = map_data,

  6. var = "Percentage_Remain",

  7. breaks = seq(0,100,10),

  8. col = cols,

  9. legend.pos = "topright",

  10. legend.title.txt = "",

  11. legend.values.rnd = 2,

  12. add = TRUE)

?


R語言空間可視化:繪制英國脫歐投票地圖的評論 (共 條)

分享到微博請遵守國家法律
潢川县| 吴旗县| 通海县| 嵊泗县| 邯郸市| 密山市| 邹平县| 文水县| 阳高县| 双峰县| 黎川县| 临猗县| 扎鲁特旗| 陵川县| 永德县| 郑州市| 四平市| 高邑县| 隆昌县| 通化市| 延长县| 武定县| 桂东县| 博爱县| 常德市| 鄱阳县| 平凉市| 建瓯市| 汝阳县| 阿图什市| 洱源县| 凤台县| 静安区| 麦盖提县| 阳东县| 高雄市| 梨树县| 通许县| 乐山市| 榆社县| 宁远县|