How to remove warning messages in R Markdown document?

37,759

Solution 1

If you want to turn off messages and warnings in the whole document you can use this code chunk right after the yaml portion.

```{r setup, include=FALSE} 
knitr::opts_chunk$set(warning = FALSE, message = FALSE) 
```

Solution 2

  1. To fix the .Rmd to stifle all warnings entirely, in the initial setup chunk in the document, add ```{r setup, warning=FALSE}
  2. For your post-knit HTML document you can always just open it in the browser, like chrome for instance, right-click on the warning then choose select element to see the HTML that makes up the displayed warning and then remove that from the HTML file without having to knit the R Markdown again.
Share:
37,759
Niranjan Agnihotri
Author by

Niranjan Agnihotri

Updated on July 09, 2022

Comments

  • Niranjan Agnihotri
    Niranjan Agnihotri almost 2 years

    I have an R Markdown document, which takes a really long time to knit because of heavy computations. Mistakenly there are some code chunks where I forgot to put warnings=False before knitting the document. Is their any way to remove those warning messages, without knitting the document again?? Is there any way to remove warnings from the Markdown document and rebuild an html file from the markdown. I don't want to execute the code again. Need the similar changes in the markdown document as well.