Thursday, August 7, 2025

xfun::attr() error in R

 I was getting errors in my pdf output files after rendering them.

## Warning in attr(.knitEnv$meta, "knit_meta_id"): 'xfun::attr()' is deprecated. ## Use 'xfun::attr2()' instead. ## See help("Deprecated")

This should be a problem with xfun/knitr packages of R. I tried to update them with no help. None of  the commands

 warning=FALSE

 knitr::opts_chunk$set(warning = FALSE)

options(warn = -1) 

would help neither. I then asked a solution to ChatGPT and it proposed the following hacky way which worked like a charm

sink("tmp.txt")
suppressWarnings(rmarkdown::render("path/to/yourfile.rmd"))
sink()

 

No comments:

Post a Comment