为什么使用 kableExtra 库错误地将 RMarkdown 的输出格式化为 Word

Why using kableExtra library wrongly formats output of RMarkdown to Word

如果我取消注释 kableExtra 库,Word 输出的格式就会错误,但 html 输出总是正确的。 kableExtra 与编织到 Word 兼容吗?


标题:“kableExtra2Word” 输出: word_document:默认 html_document: 默认

knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
library(knitr)
#library(kableExtra)
library(janitor)
MT <- tibble(Session = c(1,1,1,1,1,1,2,2,2,2),
              scores = rep('Not', 10),
              B_A = rep('A', 10))
t <- MT %>%
    tabyl(Session, scores, B_A, show_missing_levels = FALSE) %>%
    adorn_totals(where = "col")
kable(t)

kableExtra 似乎与 Word 输出不兼容,您可以尝试其他替代方法。示例 - flextable::regulartable

```{r}
MT <- tibble(Session = c(1,1,1,1,1,1,2,2,2,2),
              scores = rep('Not', 10),
              B_A = rep('A', 10))
t <- MT %>%
    tabyl(Session, scores, B_A, show_missing_levels = FALSE) %>%
    adorn_totals(where = "col")
flextable::regulartable(t$A)