1

目前kableExtra0.5.1 只支持指定选中行的外观。我想知道是否有任何调整来以编程方式指定所选行的外观,例如row_spec(x, c(1, 3, 4), bold = TRUE, italic = TRUE). 谢谢

library(knitr)
library(kableExtra)

x <- knitr::kable(head(mtcars), "latex")
kableExtra::row_spec(x, 1, bold = TRUE, italic = TRUE)
4

1 回答 1

3

您可以循环执行。

multirow_spec <- function(x, rows, ...) {
  for (row in rows) 
    x <- kableExtra::row_spec(x, row, ...)
  x
}

x <- knitr::kable(head(mtcars), "latex")
multirow_spec(x, c(1, 3, 4), bold = TRUE, italic = TRUE)
于 2017-09-10T17:22:54.227 回答