r - 纽约数据的 tract_choropleth
问题描述
我正在尝试使用 tract_choropleth复制 Ari 的ACS 演讲中显示的地图。但是,代码不断返回错误消息。我已请求 api 密钥和 state_choropleth() 和 County_choropleth() 等其他功能工作得很好。
library(choroplethr)
library(choroplethrMaps)
#api.key.install(DONE)
ny_tract = get_tract_demographics("new york", endyear = 2015)
ny_tract$value = ny_tract$per_capita_income
tract_choropleth(ny_tract, state_name="new york", title='2015 map of NY',
legend = "dollars", num_colors = 1, county_zoom = 36061)
错误消息是
Error in maptools::unionSpatialPolygons(cp, attr[,region]): isTRUE(gpclibPermitStatus()) is not TRUE
我可以看到数据框 ny_tract 加载了许多由强制警告引入的 NA。
谢谢您的帮助。
解决方案
该错误是由于gpclibPermitStatus()
返回 FALSE。
不幸的是,这是使用 choroplethr 时出现的常见错误。我曾经在这里对这个问题给出了一个冗长的回答。
简短的回答是输入以下内容:
install.packages("gpclib")
library(maptools)
gpclibPermit()
推荐阅读
- php - 如何从 Archive.php WordPress 中排除类别
- python - 创建“raveled”人脸图像 sklearn.datasets.fetch_lfw_people
- wordpress - 为什么我的 Facebook 的 iframe 代码仅在移动设备上不显示视频描述?
- sql - 使用案例表达式获取每个条件的计数和百分比
- mysql - 如何选择出生日期在 1970 年之后和 1990 年之前的所有用户的姓名和地址
- osrm - 如何在运行时优化中使用“提示”?
- flutter - Flutter - cloud_firestore 2.5.x- null 安全更新:查询 startAfterDocument 保持从第一个文档初始化
- javascript - Uncaught ReferenceError: jQuery is not defined Django jQuery CDN
- php - 如何在 HTML 中正确使用 action 属性?
- selenium - Selenium 4 不再加载 Firefox 驱动程序