可以通过tab_spanner()函数实现:
tab %
tab_spanner(label = "Performance",
columns = c...(mpg_c,mpg_h,hp,hp_rpm,trq,trq_rpm)
)
tab
image-20220514144700364
合并列 & 添加标签
和dplyr包中的...cols_align()函数更改对齐方式;使用tab_style()函数更改主题风格、颜色背景等
tab <-
tab %>%
cols_align( # 某些列使用居中对齐
align = "center...列
fn = function(x) {
# transmission这一列中每行的第一个字符表示speed
speed <- substr(x, 1, 1...)
# 第2-3个字符表示type,共分成4中type
type <-
dplyr::case_when(
substr(x,