手头的任务是将emppremisypct值映射到一个县地图。示例数据如下所示。
library(tidyverse)
library(tigris)
countyname <- c("Carson City","Churchill County","Clark County","Douglas County","Elko County","Esmeralda County","Eureka County","Humboldt County","Lander County","Lincoln County","Lyon County","Mineral County","Nye County","Pershing County","Storey County","Washoe County","White Pine County")
prevyearpct <- c(.545,.541,.539,.401,.301,.201,.101,.001,.664,.604,.704,.123,.129,.130,.085,.015,.099)
data2 <- data.frame(countyname, prevyearpct)
下面是我在Tigris中用来获取形状文件的代码。
NV_counties <- counties(32)
我不需要为我做这些工作。如果我要将之前的年率值映射到县,我应该从哪里开始呢?是否需要追加数据才能使NV_Counties和data2成为一个合并项?我已经读了相当多的文章/教程,但还没有使用tigris的文章。
发布于 2021-04-27 19:44:12
您可以使用geo_join()
将两个数据集连接在一起。之后,您可以使用geom_sf()
将其映射出来(this guide可能会有所帮助)。
https://stackoverflow.com/questions/67289009
复制