0

我正在使用 R 中的 usmap 包来创建美国的热图。我的数据是县/fips 级别的。我已成功将它们渲染成地图,但想删除县边界并留在州边界。有人知道怎么做这个吗?

数据:下载

代码:

  mapdata <- read.csv("File location here",header = T)
  yr <- 2008
  yrstr <- toString(yr)

  # Subset to relevant year and variables
  yrdata <- subset(mapdata, year == yr)
  yrdata1 <- yrdata[,c("fips_code","eligibles")]
  colnames(yrdata1)[1] <- "fips"

  plot_usmap("states", data = yrdata1, value = "eligibles", color = "white", size = 0) + 
    scale_fill_continuous(low = "blue", high = "red", name = paste0("Medicare Eligible Population (",yrstr,")"), label = scales::comma) +
    theme(legend.position = "right")
4

0 回答 0