我还希望将state列更改为FIPS代码。我不确定要使用什么参数,也不知道该怎么做,因为我刚接触R。
下面是R给出的参数:
plot_usmap(regions = c("states", "state", "counties", "county"),
include = c(), data = data.frame(), values = "values",
theme = theme_map(), lines = "black", labels = FALSE,
label_color = "black")发布于 2018-11-10 05:25:23
在没有示例的情况下,还不清楚您到底想要实现什么,但下面是我如何将data.frame中的列state从缩写转换为FIPS代码:
> library(usmap)
> df <- statepop[1:5, -1]
> names(df)[1] <- 'state'
> df
# A tibble: 5 x 3
state full pop_2015
<chr> <chr> <dbl>
1 AL Alabama 4858979
2 AK Alaska 738432
3 AZ Arizona 6828065
4 AR Arkansas 2978204
5 CA California 39144818
> df$fips <- fips(df$state)
> df
# A tibble: 5 x 4
state full pop_2015 fips
<chr> <chr> <dbl> <chr>
1 AL Alabama 4858979 01
2 AK Alaska 738432 02
3 AZ Arizona 6828065 04
4 AR Arkansas 2978204 05
5 CA California 39144818 06 https://stackoverflow.com/questions/53233246
复制相似问题