Why can I not knit to PDF when kableExtra is specified?

Rendering to PDF on RMarkdown stops right at my first code chunk where I load packages:

knitr::opts_chunk$set(echo = TRUE)

library(dplyr)
library(tidyverse)
library(haven)
library(binom)
library(ggplot2)
library(DescTools)
library(emmeans)
library(tableone)
library(kableExtra)

I get this error:




processing file: Exercise1_Chiodo.Rmd
  |...                                                |   6% [setup]           
Quitting from lines 14-26 [setup] (Exercise1_Chiodo.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]](cond)
Execution halted

It works when I remove library(kableExtra) (but then of course halts at my kable tables). What could I be doing wrong? I’ve tried to update the package and I am still getting this same error.

  • Have you tried running this code in a new session.

    – 

  • Yes, I have. I still get the same error.

    – 

  • Try loading only the kablextra package in the rmd and check what happens

    – 

  • I am able to load kableextra in the rmd with no problems – it is only when I try to knit that I get an error. If I remove all packages except for kableextra and try to knit, I still get the same error.

    – 

  • 1

    stackoverflow.com/questions/73363589/…. Would this be helpful

    – 

Leave a Comment