目前kableExtra 0.5.1
仅支持将表格的几行放入一个类别。我想知道是否有任何调整将表格中的几行放入多个类别,如group_rows(kable_input = x, group_label = c("Group 1", "Group 2"), start_row = c(1, 5), end_row = c(2, 6))
。感谢
library(knitr)
library(kableExtra)
x <- knitr::kable(head(mtcars, 10), "latex")
kableExtra::group_rows(kable_input = x, group_label = c("Group 1", "Group 2"), start_row = c(1, 5), end_row = c(2, 6))
答案 0 :(得分:1)
使用kableExtra
的开发版,您可以使用index
选项以与add_header_above()
类似的方式对行进行分组。
kable(mtcars[1:10, 1:5], "latex", booktabs = T) %>%
group_rows(index = c(" " = 3, "Group 1" = 3, "Group 2" = 4))