sbac
sbac

Reputation: 2081

Why using kableExtra library wrongly formats output of RMarkdown to Word

If I uncomment kableExtra library the Word output becomes wrongly formatted but htmloutput is always right. Is kableExtra compatible with knitting to Word?


title: "kableExtra2Word" output: word_document: default html_document: default

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)

Upvotes: 0

Views: 113

Answers (1)

Ronak Shah
Ronak Shah

Reputation: 389235

kableExtra doesn't seem to be compatible with Word output, you may try other alternatives. Example - 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)

enter image description here

Upvotes: 1

Related Questions