任何人都可以告訴我如何填補我的choropleth空白領域?我附上了我創作的血統書的照片。非常感謝!如何填寫r中的空白? ggplot2和地圖
我注意到兩個表中Statename的不匹配,但我不能夠改變Statename的在我的原始數據。
library(ggplot2)
library(maps)
**#Data looks like this:**
aggrev2015<-data.frame(
statename=c("alabama","alaska","arizona","arkansas","california","colorado","connecticut","delaware","florida","georgia","hawaii","idaho","illinois","indiana","iowa","kansas","kentucky","louisiana","maine","maryland","massachusetts","michigan", "minnesota","mississippi","missouri","montana","nebraska","nevada","new hampshire","new jersey","new mexico","new york","north carolina","north dakota","ohio","oklahoma", "oregon","pennsylvania","rhode island","south carolina","south dakota","tennessee","texas","utah","vermont","virginia","washington","west virginia","wisconsin","wyoming"),
revenue=runif(50,min=100,max=9000))
state_df <- map_data("state")
colnames(state_df)<-c("long","lat","group","order","statename","subregion")
choropleth <- merge(aggrev2015,state_df, by = "statename")
ggplot(choropleth, aes(long, lat, group = statename)) +
geom_polygon(aes(fill = revenue))
您沒有附加任何圖片,您是否真的沒有提供任何與任何人合作的數據。我會建議將你的「阿拉斯加/夏威夷」問題作爲一個單獨的問題,並且你是否已經完成了關於在美國地圖上添加HI和AK的研究?在研究中你遇到過http://rud.is/b/2014/11/16/moving-the-earth-well-alaska-hawaii-with-r/嗎? – hrbrmstr
感謝您添加圖片鏈接。我擴大了它。在看過那張地圖後,你可能會更好地使用'choroplethr'軟件包(它在CRAN中)。 – hrbrmstr