R 使用美国州和地区缩写,并希望转换为全名
abbr2state(openintro库中的一个函数)不起作用,因为它似乎在美国领土上不起作用。我可以使用哪些库等 即 如果我使用abbr2state,它只会忽略这些区域。幸运的是,这已经在R中实现了(像许多其他有用的东西一样)R 使用美国州和地区缩写,并希望转换为全名,r,R,abbr2state(openintro库中的一个函数)不起作用,因为它似乎在美国领土上不起作用。我可以使用哪些库等 即 如果我使用abbr2state,它只会忽略这些区域。幸运的是,这已经在R中实现了(像许多其他有用的东西一样) cbind(state.abb,state.name) 将为您提供所需的输出 state.abb state.name [1,] "AL" "Alabama" [2,] "AK" "Alaska" [3,] "AZ"
cbind(state.abb,state.name)
将为您提供所需的输出
state.abb state.name
[1,] "AL" "Alabama"
[2,] "AK" "Alaska"
[3,] "AZ" "Arizona"
[4,] "AR" "Arkansas"
[5,] "CA" "California"
[6,] "CO" "Colorado"
编辑::
要获得领土,您还可以使用USABunders软件包:
install.packages('USAboundaries')
library(USAboundaries)
#lookuptable territorys :
state_codes[state_codes$jurisdiction_type == "territory",]
#state_name state_abbr state_code jurisdiction_type
# <chr> <chr> <chr> <chr>
#1 American Samoa "AS" 60 territory
#2 Federated States of Micronesia "FM" 64 territory
#3 Guam "GU" 66 territory
#4 Johnson Atoll "" 67 territory
#5 Marshall Islands "MH" 68 territory
#6 Northern Mariana Islands "MP" 69 territory
#7 Palau "PW" 70 territory
#8 Midway Islands "" 71 territory
#9 Puerto Rico "PR" 72 territory
install.packages('usabundries'))
图书馆(美国)
#可查找的地域:
州代码[州代码$辖区类型==“地区”,]
#州\名称州\缩写州\代码管辖权\类型
#
#1美属萨摩亚“作为”60个领土
#2密克罗尼西亚联邦“FM”64领土
#3关岛“古”66领土
#4约翰逊环礁“67领土
#5马绍尔群岛“MH”68领土
#6北马里亚纳群岛“MP”69领土
#7帕劳“PW”70领土
#8中途岛“71领土
#9波多黎各“PR”72领土
幸运的是,这(像许多其他有用的东西一样)已经在R中实现了
cbind(state.abb,state.name)
将为您提供所需的输出
state.abb state.name
[1,] "AL" "Alabama"
[2,] "AK" "Alaska"
[3,] "AZ" "Arizona"
[4,] "AR" "Arkansas"
[5,] "CA" "California"
[6,] "CO" "Colorado"
编辑::
要获得领土,您还可以使用USABunders软件包:
install.packages('USAboundaries')
library(USAboundaries)
#lookuptable territorys :
state_codes[state_codes$jurisdiction_type == "territory",]
#state_name state_abbr state_code jurisdiction_type
# <chr> <chr> <chr> <chr>
#1 American Samoa "AS" 60 territory
#2 Federated States of Micronesia "FM" 64 territory
#3 Guam "GU" 66 territory
#4 Johnson Atoll "" 67 territory
#5 Marshall Islands "MH" 68 territory
#6 Northern Mariana Islands "MP" 69 territory
#7 Palau "PW" 70 territory
#8 Midway Islands "" 71 territory
#9 Puerto Rico "PR" 72 territory
install.packages('usabundries'))
图书馆(美国)
#可查找的地域:
州代码[州代码$辖区类型==“地区”,]
#州\名称州\缩写州\代码管辖权\类型
#
#1美属萨摩亚“作为”60个领土
#2密克罗尼西亚联邦“FM”64领土
#3关岛“古”66领土
#4约翰逊环礁“67领土
#5马绍尔群岛“MH”68领土
#6北马里亚纳群岛“MP”69领土
#7帕劳“PW”70领土
#8中途岛“71领土
#9波多黎各“PR”72领土
你能举一些例子吗?更新后的问题。什么是abbr2state
?看起来你是在要求一个查找表,但这类资源问题与SOC无关。你可以检查地图
包吗?你可以展示一些示例吗?更新后的问题。什么是abbr2state
?看起来你要求的是一个查找表,但这类资源问题与SOC无关。你可以查看映射
包吗