所有作品合集传送门: Tidy Tuesday
2018 年合集传送门: 2018
ACS Census Data (2015)
欢迎来到`ggplot2`的世界!
ggplot2是一个用来绘制统计图形的 R 软件包。它可以绘制出很多精美的图形,同时能避免诸多的繁琐细节,例如添加图例等。
用 ggplot2 绘制图形时,图形的每个部分可以依次进行构建,之后还可以进行编辑。ggplot2 精心挑选了一系列的预设图形,因此在大部分情形下可以快速地绘制出许多高质量的图形。如果在格式上还有额外的需求,也可以利用 ggplot2 中的主题系统来进行定制, 无需花费太多时间来调整图形的外观,而可以更加转注地用图形来展现你的数据。




1. 一些环境设置
# 设置为国内镜像, 方便快速安装模块
options("repos" = c(CRAN = "https://mirrors.tuna.tsinghua.edu.cn/CRAN/"))
2. 设置工作路径
wkdir <- '/home/user/R_workdir/TidyTuesday/2018/2018-04-30_ACS_Census_Data/src-a'
setwd(wkdir)
3. 加载 R 包
# 一些 R 并非是 CRAN 官方镜像里面的, 是存放在 GitHub 中
# remotes::install_gitlab("hrbrmstr/albersusa")
# devtools::install_github(c('ramnathv/htmlwidgets', 'ramnathv/rcstatebin'))
library(Hmisc)
library(maps)
library(albersusa)
library(tidyverse)
library(plotly)
library(choroplethr)
library(choroplethrMaps)
library(geojsonio)
library(broom)
library(rgeos)
library(viridis)
library(rcstatebin)
library(statebins)
# 导入字体设置包
library(showtext)
# font_add_google() showtext 中从谷歌字体下载并导入字体的函数
# name 中的是字体名称, 用于检索, 必须严格对应想要字体的名字
# family 后面的是代码后面引用时的名称, 自己随便起
# 需要能访问 Google, 也可以注释掉下面这行, 影响不大
# font_families_google() 列出所有支持的字体, 支持的汉字不多
# http://www.googlefonts.net/
font_add_google(name = "ZCOOL XiaoWei", family = "zxw")
font_add_google(name = "Gochi Hand", family = "gochi")
# 后面字体均可以使用导入的字体
showtext_auto()
4. 加载数据
# 加载数据对象
# https://team.carto.com/u/andrew/tables/andrew.us_states_hexgrid/public/map
df_input <- read.csv("../data/week5_acs2015_county_data.csv")
df_sp <- geojson_read("../data/us_states_hexgrid.geojson", what = "sp")
# 简要查看数据内容
glimpse(df_input)
## Rows: 3,220
## Columns: 37
## $ CensusId <int> 1001, 1003, 1005, 1007, 1009, 1011, 1013, 1015, 1017, …
## $ State <chr> "Alabama", "Alabama", "Alabama", "Alabama", "Alaalbert",…
## $ County <chr> "Autauga", "Baldwin", "Barbour", "Bibb", "Blount", "Bu…
## $ TotalPop <int> 55221, 195121, 26932, 22604, 57710, 10678, 20354, 1166…
## $ Men <int> 26745, 95314, 14497, 12073, 28512, 5660, 9502, 56274, …
## $ Women <int> 28476, 99807, 12435, 10531, 29198, 5018, 10852, 60374,…
## $ Hispanic <dbl> 2.6, 4.5, 4.6, 2.2, 8.6, 4.4, 1.2, 3.5, 0.4, 1.5, 7.6,…
## $ White <dbl> 75.8, 83.1, 46.2, 74.5, 87.9, 22.2, 53.3, 73.0, 57.3, …
## $ Black <dbl> 18.5, 9.5, 46.7, 21.4, 1.5, 70.7, 43.8, 20.3, 40.3, 4.…
## $ Native <dbl> 0.4, 0.6, 0.2, 0.4, 0.3, 1.2, 0.1, 0.2, 0.2, 0.6, 0.4,…
## $ Asian <dbl> 1.0, 0.7, 0.4, 0.1, 0.1, 0.2, 0.4, 0.9, 0.8, 0.3, 0.3,…
## $ Pacific <dbl> 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,…
## $ Citizen <int> 40725, 147695, 20714, 17495, 42345, 8057, 15581, 88612…
## $ Income <dbl> 51281, 50254, 32964, 38678, 45813, 31938, 32229, 41703…
## $ IncomeErr <dbl> 2391, 1263, 2973, 3995, 3141, 5884, 1793, 925, 2949, 1…
## $ IncomePerCap <int> 24974, 27317, 16824, 18431, 20532, 17580, 18390, 21374…
## $ IncomePerCapErr <int> 1080, 711, 798, 1618, 708, 2055, 714, 489, 1366, 1556,…
## $ Poverty <dbl> 12.9, 13.4, 26.7, 16.8, 16.7, 24.6, 25.4, 20.5, 21.6, …
## $ ChildPoverty <dbl> 18.6, 19.2, 45.3, 27.9, 27.2, 38.4, 39.2, 31.6, 37.2, …
## $ Professional <dbl> 33.2, 33.1, 26.8, 21.5, 28.5, 18.8, 27.5, 27.3, 23.3, …
## $ Service <dbl> 17.0, 17.7, 16.1, 17.9, 14.1, 15.0, 16.6, 17.7, 14.5, …
## $ Office <dbl> 24.2, 27.1, 23.1, 17.8, 23.9, 19.7, 21.9, 24.2, 26.3, …
## $ Construction <dbl> 8.6, 10.8, 10.8, 19.0, 13.5, 20.1, 10.3, 10.5, 11.5, 1…
## $ Production <dbl> 17.1, 11.2, 23.1, 23.7, 19.9, 26.4, 23.7, 20.4, 24.4, …
## $ Drive <dbl> 87.5, 84.7, 83.8, 83.2, 84.9, 74.9, 84.5, 85.3, 85.1, …
## $ Carpool <dbl> 8.8, 8.8, 10.9, 13.5, 11.2, 14.9, 12.4, 9.4, 11.9, 12.…
## $ Transit <dbl> 0.1, 0.1, 0.4, 0.5, 0.4, 0.7, 0.0, 0.2, 0.2, 0.2, 0.2,…
## $ Walk <dbl> 0.5, 1.0, 1.8, 0.6, 0.9, 5.0, 0.8, 1.2, 0.3, 0.6, 1.1,…
## $ OtherTransp <dbl> 1.3, 1.4, 1.5, 1.5, 0.4, 1.7, 0.6, 1.2, 0.4, 0.7, 1.4,…
## $ WorkAtHome <dbl> 1.8, 3.9, 1.6, 0.7, 2.3, 2.8, 1.7, 2.7, 2.1, 2.5, 1.9,…
## $ MeanCommute <dbl> 26.5, 26.4, 24.1, 28.8, 34.9, 27.5, 24.6, 24.1, 25.1, …
## $ Employed <int> 23986, 85953, 8597, 8294, 22189, 3865, 7813, 47401, 13…
## $ PrivateWork <dbl> 73.6, 81.5, 71.8, 76.8, 82.0, 79.5, 77.4, 74.1, 85.1, …
## $ PublicWork <dbl> 20.9, 12.3, 20.8, 16.1, 13.5, 15.1, 16.2, 20.8, 12.1, …
## $ SelfEmployed <dbl> 5.5, 5.8, 7.3, 6.7, 4.2, 5.4, 6.2, 5.0, 2.8, 7.9, 4.1,…
## $ FamilyWork <dbl> 0.0, 0.4, 0.1, 0.4, 0.4, 0.0, 0.2, 0.1, 0.0, 0.5, 0.5,…
## $ Unemployment <dbl> 7.6, 7.5, 17.6, 8.3, 7.7, 18.0, 10.9, 12.3, 8.9, 7.9, …
# 检查数据的列名
colnames(df_input)
## [1] "CensusId" "State" "County" "TotalPop"
## [5] "Men" "Women" "Hispanic" "White"
## [9] "Black" "Native" "Asian" "Pacific"
## [13] "Citizen" "Income" "IncomeErr" "IncomePerCap"
## [17] "IncomePerCapErr" "Poverty" "ChildPoverty" "Professional"
## [21] "Service" "Office" "Construction" "Production"
## [25] "Drive" "Carpool" "Transit" "Walk"
## [29] "OtherTransp" "WorkAtHome" "MeanCommute" "Employed"
## [33] "PrivateWork" "PublicWork" "SelfEmployed" "FamilyWork"
## [37] "Unemployment"
5. 数据预处理
# 以州进行分组, 分别计算平均值
df_alb <- df_input %>%
group_by(State) %>%
summarise(MeanCommute = sum(MeanCommute * TotalPop)/sum(TotalPop))
6. 利用 ggplot2 绘图
6.1 利用 albersusa 绘制地图热图
# 获得 albersusa 包中美国州县复合地图数据
uscnty <- counties_composite()
# 获得美国地图数据
usmap <- broom::tidy(uscnty, region = "fips") %>%
tibble::as_tibble() %>%
dplyr::mutate(id = as.integer(id))
# PS: 方便讲解, 我这里进行了拆解, 具体使用时可以组合在一起
gg <- usmap %>%
# 通过 usmap 中的 id 与 df_input 中的 CensusId 关联在一起
left_join(df_input, by = c("id" = "CensusId")) %>%
# 以 long 为横坐标, lat 为纵坐标, group 为分组信息建立 ggplot2 画布
ggplot(aes(long, lat, group = group))
# geom_polygon() 绘制的是多边形
gg <- gg + geom_polygon(aes(fill = MeanCommute), colour = "grey")
# coord_quickmap() 为地图设置合适的纵横比, 调整轴以确保经度和纬度以相同的比例呈现
gg <- gg + coord_quickmap()
# scale_fill_distiller() 色块连续过度, 通过 ?scale_fill_distiller 打开帮助页面, 在 Palettes 章节可以获得支持的所有 palette 值
gg <- gg + scale_fill_distiller(name = "通勤时间(分钟)", palette = "BrBG")
# guides() 设置图例信息
gg <- gg + guides(fill = guide_legend(frame.color = "white", title.position = "top", label.position = "bottom"))
# theme_minimal() 去坐标轴边框的最小化主题
gg <- gg + theme_minimal()
# labs() 对图形添加注释和标签(包含标题 title、子标题 subtitle、坐标轴 x & y 和引用 caption 等注释)
gg <- gg + labs(x = NULL,
y = NULL,
title = '2015年 - 全美通勤通勤时间',
caption = '数据来源: 2015年美国人口普查数据 | GRAPH: 数绘小站')
# theme() 实现对非数据元素的调整, 对结果进行进一步渲染, 使之更加美观
gg <- gg + theme(
# panel.grid.major 主网格线
panel.grid.major = element_line(colour = "#333333", size = 0.25),
# plot.background 图片背景
plot.background = element_blank(),
# plot.margin 调整图像边距, 上-右-下-左
plot.margin = unit(c(.15, .1, .15, 0.1), "cm"),
# plot.title 主标题
plot.title = element_text(color = "black", size = 24, face = "bold", vjust = -0.5, family = 'zxw'),
# axis.text 坐标轴刻度文本
axis.text = element_text(size = 16, face = "bold"),
# legend.position 设置图例位置, 这里设置图例的绝对位置
legend.position = c(0.88 , .165),
# legend.direction 设置图例的方向 horizontal 表示水平摆放
legend.direction = "horizontal",
# legend.background 设置图例的背景
legend.background = element_blank())
gg

6.2 利用 choroplethr 绘制地图热图
# 选择此次绘图所需要的列, 并重命名
de_commute <- df_input %>%
select(CensusId, MeanCommute) %>%
rename(region = CensusId, value = MeanCommute)
# PS: 方便讲解, 我这里进行了拆解, 具体使用时可以组合在一起
# 创建一个州县级别的的 chorpleth 对象
choro <- CountyChoropleth$new(de_commute)
# 主标题
choro$title <- "2015年 - 全美通勤通勤时间"
# scale_fill_brewer() 一般用于箱线图和条形图等需要填充图的配色
choro$ggplot_scale <- scale_fill_brewer(name = "通勤时间(分钟)", palette = 3, drop = FALSE)
# 绘制图片, 或者交接给 ggplot2 进行进一步设置
hh <- choro$render()
# theme_minimal() 去坐标轴边框的最小化主题
hh <- hh + theme_minimal()
# labs() 对图形添加注释和标签(包含标题 title、子标题 subtitle、坐标轴 x & y 和引用 caption 等注释)
hh <- hh + labs(x = NULL,
y = NULL,
title = '2015年 - 全美通勤通勤时间',
caption = '数据来源: 2015年美国人口普查数据 | GRAPH: 数绘小站')
# theme() 实现对非数据元素的调整, 对结果进行进一步渲染, 使之更加美观
hh <- hh + theme(
# panel.grid.major 主网格线
panel.grid.major = element_line(colour = "#333333", size = 0.25),
# plot.background 图片背景
plot.background = element_rect(color = '#F5F5DC', fill = '#F5F5DC', size = 2),
# plot.margin 调整图像边距, 上-右-下-左
plot.margin = unit(c(.15, .1, .15, 0.1), "cm"),
# plot.title 主标题
plot.title = element_text(color = "black", size = 24, face = "bold", vjust = -0.5, family = 'zxw'),
# axis.text 坐标轴刻度文本
axis.text = element_text(size = 16, face = "bold"),
# legend.position 设置图例位置, 这里设置图例的绝对位置
legend.position = c(0.922 , .245),
# legend.direction 设置图例的方向 vertical 表示垂直摆放
legend.direction = "vertical",
# legend.background 设置图例的背景, 背景为白色, 且图例边框无
legend.background = element_rect(fill='white', colour = 'transparent'))
hh

6.3 利用 statebins 绘制交互式六边形网格地图/蜂窝地图
# state.name 美国各个州的名字全称
# state.abb 美国各个州的名字缩写
df_state <- tibble(State = state.name) %>%
bind_cols(tibble(ST = state.abb)) %>%
# 新增两行数据
bind_rows(tibble(State = "District of Columbia", ST = "DC")) %>%
bind_rows(tibble(State = "Puerto Rico", ST = "PR"))
# 整理绘图数据, 合并州名, 便于绘制地图
df_plot <- df_input %>%
# group_by() 以指定的列进行分组
group_by(State) %>%
# 对 Hispanic 至 Pacific 列之间的数据进行操作
mutate_at(vars(Hispanic : Pacific), funs(. * TotalPop / 100)) %>%
# 对 TotalPop 至 Pacific 列之间的数据进行操作, 求和
summarise_at(vars(TotalPop : Pacific), sum, na.rm = TRUE) %>%
group_by(State) %>%
mutate_at(vars(Men : Pacific), funs(round(. / TotalPop * 100, 3))) %>%
# 合并州名
left_join(df_state, by = 'State') %>%
# gather() 数据收缩、从宽表到长表. key 将原数据框中所有的列赋值给这个变量; value 将原数据框中所有的值赋值给这个变量
gather(TotalPop:Pacific, key = "facet", value = "share") %>%
# 剔除 ST == PR 的数据
filter(ST != "PR")
# statebin() 用于创建交互式状态箱地图
# statebins 包只能绘制美国的地图
ii <- statebin(data = df_plot,
x = "ST",
y = "share",
facet = "facet",
heading = "<b>美国国家人口普查</b>",
footer = "<small>数据来源: 2015年美国人口普查数据 | GRAPH: 数绘小站",
colors = RColorBrewer::brewer.pal(5, 'PuRd'),
control = 'dropdown')
ii
注:这是一个动态查询表格,这里不好展示,就截了一个图~

6.4 利用 ggplot2 绘制六边形网格地图/蜂窝地图
# 整理绘图数据
# 将名字中的 United States 部分剔除, 只保留州的名字
df_sp@data <- df_sp@data %>% mutate(name = gsub(" \\(United States\\)", "", google_name))
# 将数据转换成一个 tidy tibble
df_bert <- generics::tidy(df_sp, region = "name")
# 获得美国各州经纬度数据和缩写名称, 用于地图文字标注
albert <- cbind.data.frame(data.frame(gCentroid(df_sp, byid = TRUE), id = df_sp@data$iso3166_2))
df_bert <- left_join(df_bert, df_input, by = c("id" = "State"))
# 划分 bin, 即热图的刻度
df_bert$bin <- cut(df_bert$MeanCommute,
breaks = c(seq(10, 35, by = 5), Inf),
labels = c(seq(10, 30, by = 5), "35+"),
include.lowest = TRUE)
# 自定义绘图配色版
palette <- rev(magma(8))[c(-1,-8)]
# PS: 方便讲解, 我这里进行了拆解, 具体使用时可以组合在一起
jj <- ggplot()
# geom_polygon() 绘制的是多边形
jj <- jj + geom_polygon(data = df_bert, aes(fill = bin, x = long, y = lat, group = group))
# geom_text() 添加文本信息, 将美国各州的缩写根据经纬度坐标添加到图片中
jj <- jj + geom_text(data = albert, aes(x = x, y = y, label = id), color = "#F8F8FF", size = 4.2, alpha = 0.72, family = "gochi")
# scale_fill_manual() 采取的是手动赋值的方法, 也就是直接把颜色序列赋值给它的参数 value
jj <- jj + scale_fill_manual(values = palette, name="通勤时间(分钟)",
guide = guide_legend(keyheight = unit(3.5, units = "mm"),
keywidth=unit(14, units = "mm"),
label.position = "top",
title.position = 'bottom', nrow = 1))
# coord_map() 坐标系转换成地理坐标系
jj <- jj + coord_map()
# theme_minimal() 去坐标轴边框的最小化主题
jj <- jj + theme_minimal()
# labs() 对图形添加注释和标签(包含标题 title、子标题 subtitle、坐标轴 x & y 和引用 caption 等注释)
jj <- jj + labs(x = NULL,
y = NULL,
title = '2015年 - 全美通勤通勤时间',
caption = '数据来源: 2015年美国人口普查数据 | GRAPH: 数绘小站')
# theme() 实现对非数据元素的调整, 对结果进行进一步渲染, 使之更加美观
jj <- jj + theme(
# panel.grid.major 主网格线
panel.grid.major = element_line(colour = "#333333", size = 0.25),
# plot.margin 调整图像边距, 上-右-下-左
plot.margin = unit(c(.15, .1, .15, 0.1), "cm"),
# text 设置文本格式
text = element_text(color = "red", size = 12, face = "bold", family = 'zxw'),
# plot.title 主标题
plot.title = element_text(color = "black", size = 24, face = "bold", vjust = -0.5, family = 'zxw'),
# axis.text 坐标轴刻度文本
axis.text = element_text(size = 16, face = "bold"),
# legend.position 设置图例位置, 这里设置图例的绝对位置
legend.position = c(0.522 , .875),
# legend.direction 设置图例的方向 vertical 表示垂直摆放
legend.direction = "vertical",
# legend.background 设置图例的背景, 这里设置图例无背景色, 无边框
legend.background = element_blank(),
# plot.background 图片背景
plot.background = element_rect(color = '#DDA0DD', fill = '#DDA0DD', size = 2))
jj

7. 保存图片到 PDF 和 PNG
filename = '20180430-A-01'
ggsave(gg, filename = paste0(filename, ".pdf"), width = 10.2, height = 6.3, device = cairo_pdf)
ggsave(gg, filename = paste0(filename, ".png"), width = 10.2, height = 6.3, dpi = 100, device = "png", bg = 'white')
filename = '20180430-A-02'
ggsave(hh, filename = paste0(filename, ".pdf"), width = 10.2, height = 6.3, device = cairo_pdf)
ggsave(hh, filename = paste0(filename, ".png"), width = 10.2, height = 6.3, dpi = 100, device = "png")
filename = '20180430-A-04'
ggsave(jj, filename = paste0(filename, ".pdf"), width = 10.2, height = 6.3, device = cairo_pdf)
ggsave(jj, filename = paste0(filename, ".png"), width = 10.2, height = 6.3, dpi = 100, device = "png")
8. session-info
sessionInfo()
## R version 4.2.1 (2022-06-23)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 20.04.5 LTS
##
## Matrix products: albert
## BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/liblapack.so.3
##
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
## [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
## [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] showtext_0.9-5 showtextdb_3.0 sysfonts_0.8.8
## [4] statebins_1.4.0 rcstatebin_0.2 viridis_0.6.2
## [7] viridisLite_0.4.1 rgeos_0.5-9 sp_1.5-0
## [10] broom_1.0.1 geojsonio_0.10.0 choroplethrMaps_1.0.1
## [13] choroplethr_3.7.1 acs_2.1.4 XML_3.99-0.10
## [16] plotly_4.10.0 forcats_0.5.2 stringr_1.4.1
## [19] dplyr_1.0.10 purrr_0.3.4 readr_2.1.2
## [22] tidyr_1.2.1 tibble_3.1.8 tidyverse_1.3.2
## [25] albersusa_0.4.1 maps_3.4.0 Hmisc_4.7-1
## [28] ggplot2_3.3.6 Formula_1.2-4 survival_3.4-0
## [31] lattice_0.20-45
##
## loaded via a namespace (and not attached):
## [1] googledrive_2.0.0 WDI_2.7.8 colorspace_2.0-3
## [4] rjson_0.2.21 deldir_1.0-6 ellipsis_0.3.2
## [7] class_7.3-20 rgdal_1.5-32 htmlTable_2.4.1
## [10] base64enc_0.1-3 fs_1.5.2 httpcode_0.3.0
## [13] rstudioapi_0.14 proxy_0.4-27 farver_2.1.1
## [16] fansi_1.0.3 lubridate_1.8.0 xml2_1.3.3
## [19] splines_4.2.1 cachem_1.0.6 knitr_1.40
## [22] jsonlite_1.8.2 cluster_2.1.4 dbplyr_2.2.1
## [25] png_0.1-7 mapproj_1.2.8 compiler_4.2.1
## [28] httr_1.4.4 backports_1.4.1 assertthat_0.2.1
## [31] Matrix_1.5-1 fastmap_1.1.0 lazyeval_0.2.2
## [34] gargle_1.2.1 cli_3.4.1 htmltools_0.5.3
## [37] tools_4.2.1 ggmap_3.0.0 gtable_0.3.1
## [40] glue_1.6.2 geojson_0.3.4 rappdirs_0.3.3
## [43] V8_4.2.1 Rcpp_1.0.9 cellranger_1.1.0
## [46] jquerylib_0.1.4 vctrs_0.4.2 crul_1.3
## [49] tigris_1.6.1 xfun_0.32 rvest_1.0.3
## [52] lifecycle_1.0.3 googlesheets4_1.0.1 jqr_1.2.3
## [55] scales_1.2.1 ragg_1.2.3 hms_1.1.2
## [58] RColorBrewer_1.1-3 curl_4.3.2 yaml_2.3.5
## [61] gridExtra_2.3 sass_0.4.2 rpart_4.1.16
## [64] latticeExtra_0.6-30 stringi_1.7.8 highr_0.9
## [67] maptools_1.1-4 e1071_1.7-11 checkmate_2.1.0
## [70] systemfonts_1.0.4 RgoogleMaps_1.4.5.3 rlang_1.0.6
## [73] pkgconfig_2.0.3 bitops_1.0-7 evaluate_0.16
## [76] sf_1.0-8 labeling_0.4.2 htmlwidgets_1.5.4.9000
## [79] tidyselect_1.1.2 geojsonsf_2.0.3 plyr_1.8.7
## [82] magrittr_2.0.3 R6_2.5.1 generics_0.1.3
## [85] DBI_1.1.3 pillar_1.8.1 haven_2.5.1
## [88] foreign_0.8-82 withr_2.5.0 units_0.8-0
## [91] nnet_7.3-17 modelr_0.1.9 crayon_1.5.1
## [94] tidycensus_1.2.3 uuid_1.1-0 interp_1.1-3
## [97] KernSmooth_2.23-20 utf8_1.2.2 tzdb_0.3.0
## [100] rmarkdown_2.16 jpeg_0.1-9 grid_4.2.1
## [103] readxl_1.4.1 data.table_1.14.2 reprex_2.0.2
## [106] digest_0.6.29 classInt_0.4-8 textshaping_0.3.6
## [109] munsell_0.5.0 bslib_0.4.0
本文展示了如何使用ggplot2、choroplethr和statebins等R包,结合2015年美国人口普查数据,分析全美各州及县的平均通勤时间,并通过地图热图、交互式六边形网格等形式可视化结果。


被折叠的 条评论
为什么被折叠?



