kableExtra:将一个表中的几行分成许多类别编程(kableExtra: Put a few

2019-11-04 10:56发布

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

Answer 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))


文章来源: kableExtra: Put a few rows of a table into many categories programmatically