shapefile to produce a linked micromap in R

若如初见. 提交于 2019-12-07 03:14:27

The problem is that create_map_table(...) takes whatever you give it as the id column (VARNAME_1 in your case), and puts that in a column called ID in the output (statePolys in your case). So now there is a statePolys$ID column with whatever you had in VARNAME_1. When you tell lmplot(...) to join on edPov$Id1 and statePolys$VARNAME_1, it can't find the latter column. Another way to say this is that the second element of map.link must always be ID. So this code works (I used the ID_1 column in both edPov and ger here, since that seems to contain a German State ID).

library(micromap)
library(ggplot2)

ger<-readShapePoly("germany3.shp")
edPov<-read.csv('gerpoverty.csv')

statePolys <- create_map_table(ger, 'ID_1')  # ID_1 stored in statePolys$ID
head(statePolys)
lmplot(stat.data=edPov, 
       map.data=statePolys, 
       panel.types=c('labels', 'dot','map'),
       panel.data=list('Id1','poverty',NA),
       ord.by='poverty',
       grouping=5, median.row=F,
       map.link=c('ID_1','ID'))

Here, ID_1 refers to edPoly$ID_1, and ID refers to statePolys$ID.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!