![](/img/trans.png)
[英]How to get state name and how to superimpose its value on heat map plot for USA in R
[英]How to Plot ZipCodes onto a Map of USA using Counts in R
您應該嘗試提供更多可重現的代碼。
這里:
df_count <- data.frame(zip = as.character(c(94025, 98550, 94303, 94306,
94062, 94305, 94301, 94061, 943125)),
Count = c(1465, 915, 810, 768, 715,
711, 678, 630, 584))
# Loading packages
library(sf)
library(dplyr)
# loading shapefile with zip codes
zip_codes <- sf::st_read("tl_2019_us_zcta510/tl_2019_us_zcta510.shp")
# join that only keep data in df_count
zip_with_count <- zip_codes %>%
dplyr::right_join(df_count, by = c("ZCTA5CE10" = "zip"))
# quick and dirty plot
plot(zip_with_count["Count"])
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.