Abhi-1U / texor

Converting 'LaTeX' 'R Journal' Articles into 'RJ-web-articles'
https://abhi-1u.github.io/texor/
Other
6 stars 2 forks source link

rnw_to_rmd: suppress package startup messages #81

Closed hturner closed 2 weeks ago

hturner commented 1 month ago

I believe that Sweave does not show messages and warnings in the code output, but these will appear in the R markdown output.

A particular case is the messages that appear when a package is loaded, which we rarely want to see in the output.

I think we can set the following in the settings chunk, to always suppress package startup messages:

library <- function(...) suppressPackageStartupMessages(base::library(...))
fzyxh commented 1 month ago

In fact, R codes perform the same in both document expect some commands related to rendering LaTeX itself. And this is controlled by knitr when kniting R Markdown file.

For example, in system.file("examples", "sweave_article", package = "texor"), I used a setup code chunk to disable warning messages:

<<setup,include=FALSE>>=
knitr::opts_chunk$set(warning = FALSE)
@

If I delete this code chunk, it may throw warnings in both output ( pdf from Sweave and HTML from R Markdown).

image image