我正在使用choroplethr为美国建立一个新的choropleth贴图,并停留在显示对应于某个状态的值上。
我正在尝试使用choroplethr构建一个choropleth地图。我的表具有列区域和值。我成功显示了相应状态的状态名称。我还试图在状态名称上显示相应的值名称。这是我为打印州名而完成的以下代码行。
library(choroplethr)
library(choroplethrMaps)
library(dplyr)
gtd <- read.csv("50_us_state_names.csv")
statelabel <- gtd[,2:3]
colnames(statelabel) <- c("region", "value")
statelabel <- gtd[,2:3]
colnames(statelabel) <- c("region", "value")
statelabel$region <- tolower(statelabel$region)
statelabel$region <- gsub(" (u.s. state)", "", statelabel$region,
fixed=TRUE)
state_choropleth(statelabel)
除了输出映射,我同时显示状态名称和相应状态的值。