0

目前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))
4

1 回答 1

1

使用 dev 版本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))
于 2017-09-12T15:25:26.427 回答