使用County_ChoroplethR添加变量值和县名

Adding Variable Values & County Names using County_ChoroplethR

提问人:Kyle Overton 提问时间:7/16/2022 最后编辑:ProgmanKyle Overton 更新时间:7/16/2022 访问量:42

问:

我创建了一个国家/地区分区统计表来显示数据并且工作正常,我想做的是添加县名和变量附加数据(员工人数),除了填写分区统计局的工资数据之外。这可能吗?代码块中的 County 原始数据不是硬编码的,当然,它以 csv 的形式读入 R,但不知道如何共享。

library(leaflet)
library(ggplot2)
library(ggmap)
library(choroplethr)
library(choroplethrMaps)
library(sp)
library(raster)
library(rgdal)
library(tidyverse)
library(devtools)
library(knitr)
library(dplyr)
library(tmap)
library(tmaptools)
library(sf)
library(RColorBrewer)
library(rio)
library(plyr)

{CNTY   Total_Employees value   region
Arkansas    4   543040.33   5001
Bradley 1   102738.51   5011
Calhoun 1   67475.2 5013
Cleveland   6   481505.92   5025
Drew    1   129700.27   5043
Faulkner    6   707548.2    5045
Garland 4   540568  5051
Grant   45  4525191.89  5053
Hempstead   1   99804.53    5057
Jefferson   313 21032269.84 5069
Lincoln 2   130407.44   5079
Lonoke  11  1213848.15  5085
Miller  2   260067.3    5091
Pope    1   150617.18   5115
Pulaski 229 33095240.96 5119
Saline  45  5975793.76  5125
Washington  1   130187.05   5143
Ashley  0   0   5003
Baxter  0   0   5005
Benton  0   0   5007
Boone   0   0   5009
Carroll 0   0   5015
Chicot  0   0   5017
Clark   0   0   5019
Clay    0   0   5021
Cleburne    0   0   5023
Columbia    0   0   5027
Conway  0   0   5029
Craighead   0   0   5031
Crawford    0   0   5033
Crittenden  0   0   5035
Cross   0   0   5037
Dallas  0   0   5039
Desha   0   0   5041
Franklin    0   0   5047
Fulton  0   0   5049
Greene  0   0   5055
Hot Spring  0   0   5059
Howard  0   0   5061
Independence    0   0   5063
Izard   0   0   5065
Jackson 0   0   5067
Johnson 0   0   5071
Lafayette   0   0   5073
Lawrence    0   0   5075
Lee 0   0   5077
Little River    0   0   5081
Logan   0   0   5083
Madison 0   0   5087
Marion  0   0   5089
Mississippi 0   0   5093
Monroe  0   0   5095
Montgomery  0   0   5097
Nevada  0   0   5099
Newton  0   0   5101
Ouachita    0   0   5103
Perry   0   0   5105
Phillips    0   0   5107
Pike    0   0   5109
Poinsett    0   0   5111
Polk    0   0   5113
Prairie 0   0   5117
Randolph    0   0   5121
St Francis  0   0   5123
Scott   0   0   5127
Searcy  0   0   5129
Sebastian   0   0   5131
Sevier  0   0   5133
Sharp   0   0   5135
Stone   0   0   5137
Union   0   0   5139
Van Buren   0   0   5141
White   0   0   5145
Woodruff    0   0   5147
Yell    0   0   5149}

AR_Cnty <- read.csv("C:/AR_CntyData.csv", header =TRUE, sep = ',')
AR_Cnty1 <- AR_Cnty[,c(3:4)]

AR_Map <- county_choropleth(AR_Cnty1, 
                   title = "Economic Impact 2022 by County",
                   state_zoom = "arkansas",
                   num_colors = 9) 


AR_Map
r choroplethr

评论

0赞 Ari 7/16/2022
尝试使用共享数据。请参见 stackoverflow.com/a/5965451/2518602。此外,我相信您不需要对库的大多数调用来使您的示例正常工作。dput

答: 暂无答案