kableExtra:以编程方式指定所选行的外观

kableExtra: Specify the look of selected rows programatically

目前kableExtra 0.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)

你可以循环执行。

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)