gpt4 book ai didi

R map 包缺少县

转载 作者:行者123 更新时间:2023-12-04 11:38:34 24 4
gpt4 key购买 nike

我正在尝试使用 R“ map ”包按县制作美国的热图/等值线/专题图。不幸的是,数据库中似乎缺少一些县。

library(maps)
data(county.fips)
which(county.fips[,1] == 35006)
which(county.fips[,2] == 'new mexico,cibola')

结果没有找到条目

> library(maps)
> data(county.fips)
> which(county.fips[,1] == 35006)
integer(0)
> which(county.fips[,2] == 'new mexico,cibola')
integer(0)

我知道这个 fips 代码存在! (http://en.wikipedia.org/wiki/Cibola_County,_New_Mexico http://en.wikipedia.org/wiki/List_of_counties_in_New_Mexico )

有人知道我怎样才能完成我的完整情节吗?所有我能找到的都列在这里:http://grokbase.com/t/r/r-sig-geo/0964515wmd/missing-county-in-maps

感谢您的帮助!

最佳答案

啊哈,问题不在于 map ,而在于 county.fips。 Cibola 县未出现在该数据集中,因此当我将我的数据{variable-to-plot,FIPS 代码}与列表匹配时,Cibola 总是缺失。

有一个显示 Cibola 县的解决方法...为不涉及 county.fips 数据集的县写一条明确的行。

countynames <- match(county.fips[,"fips"], mydatavector$fips)
cibola_value <- mydatavector[which(mydatavector$fips == 35006)]
m <- map("county")
map("county", countynames, col=rainbow(100)[mydatavector$var_to_plot], fill=TRUE, add=TRUE)
map("county", "new mexico,cibola", col=rainbow(100)[cibola_value], fill=TRUE, add=TRUE)

注意:我还发现 map 函数在绘制美国所有县时遇到问题,但如果我将调用分成 2 个集合,它就可以正常工作。

关于R map 包缺少县,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13941586/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com