我想要将knitr中列标题与其内容对齐。有什么函数可以实现吗?当我使用align = 'c'
或position = 'c'
时,会提示错误:
未使用的参数(align="c")。
这是我的代码:
DF_3 <-structure(list(. = structure(c(11L, 6L, 7L, 8L, 13L, 5L, 4L, 2L, 12L, 3L, 1L, 10L, 9L),
.Label = c("B", "D", "E", "F", "G", "H", "H", "H", "I", "J", "M", "N", "V"), class = "f"),
HEV.pos = structure(c(3L, 8L, 1L, 6L, 2L, 9L, 8L, 10L, 7L, 3L, 8L, 4L, 5L),
.Label = c("1 (2)", "15", "16", "19", "20", "24", "26", "4 (7)", "6 (11)", "7 (13)"), class = "factor"),
HEV.neg = structure(c(9L, 2L, 7L, 1L, 6L, 1L, 7L, 10L, 5L, 4L, 8L, 3L, 5L),
.Label = c("10 (28)", "12 ", "15 ", "17", "18 ", "19 ", "2 ", "4", "7", "9"), class = "factor")),
class = "data.frame", row.names = c(NA, -13L))
library(knitr)
library(kableExtra)
library(dplyr)
kable(DF_3, format = "html") %>%
kable_styling(bootstrap_options = "striped") %>%
row_spec(1, bold = T) %>%
row_spec(6, bold = T) %>%
column_spec(1, bold = T)
DF_3
。您能否将dput(DF_3)
的输出添加到您的问题中? - Michael Harper