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:
base::library(kableExtra)
base::tryCatch(...)
base (local) tryCatchList(expr, classes, parentenv, handlers)
base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
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.
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.