kableExtra cannot be loaded when knitting

I have an R markdown file that uses the kableExtra package. If I execute the code in a console window in RStudio, it works fine. If I instead press the "knit" button to produce an HTML file, it throws the following error:

Quitting from lines 295-303 [loaddata] (912-mss-jbi.Rmd)
Error:
! package or namespace load failed for 'kableExtra':
.onLoad failed in loadNamespace() for 'kableExtra', details:
call: !is.null(rmarkdown::metadata$output) && rmarkdown::metadata$output %in%
error: 'length = 3' in coercion to 'logical(1)'
Backtrace:

  1. base::library(kableExtra)
  2. base::tryCatch(...)
  3. base (local) tryCatchList(expr, classes, parentenv, handlers)
  4. base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
  5. value[3L]

Execution halted

I am running version 2023.06.1 Build 524 of RStudio, with R version 4.3.1, and kableExtra version kableExtra_1.3.4.

More info on this issue. This is the YAMNL header of the file:


title: "KableExtra Bug"
author: "Kevin R. Coombes"
date: "Sys.Date()"
output:
html_document:
theme: yeti
highlight: kate
toc: no
word_document:
highlight: kate
reference_doc: custom-reference.docx

If you delete the part about the Word document, then kabl;eExtra loads properly when knit'ted. If the Word specification is there, even though the output is targeted to HTML, then kableExtra does not load.

Hi there,

With a few changes the code works for me
1st - you have highlight twice - please remove one of them

2nd - toc: false, otherwise it just prints "no"

3rd - date: r Sys.Date() this means you should load the library sys before the YAML block.

this is my code:

{r, echo=FALSE, warning=FALSE}

library(sys)

---
title: "KableExtra Bug"
author: "Kevin R. Coombes"
date: `r Sys.Date()`
output:
html_document:
theme: yeti
highlight: kate
toc: false
word_document:
reference_doc: custom-reference.docx
---

I have created a minimal example to reproduce the bug. But here is some updated information:

  • The bug does not appear in R 4.2.2.
  • The bug us reproducible across three windows machines (one Win 10, two Win11) when running R 4.3.1
  • If you delete or comment out the part of the YAML header referring to word_document, the bug disappears. This happens even when trying to knit to HTML output.

Here is the file:


title: "library kableExtra bug"
author: "Kevin R. Coombes"
date: "r Sys.Date()"
output:
html_document:
theme: yeti
highlight: kate
toc: false
word_document:
toc: false
always_allow_html: yes

Blah, blah, blah.

library(knitr)
library(kableExtra)
sessionInfo()

this is my session info, win11 r 4.3.1, no problem loading kableExtra. why do you need to load knitr?

my code:


title: "library kableExtra bug"
author: "Kevin R. Coombes"
date: "r Sys.Date()"
output:
html_document:
theme: yeti
highlight: kate
toc: false
word_document:
always_allow_html: yes

{r}
library(kableExtra)
sessionInfo()

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.