How to remove warning messages in an R Markdown document?

I have an R Markdown document that takes a very long time to knit due to heavy computing. Mistakenly, there are some code fragments where I forgot to put warnings=Falsebefore knitting a document. Do they have any way to remove these warning messages without inserting the document again? Is there a way to remove warnings from a Markdown document and rebuild the html file from markdowns. I do not want to execute the code again. Similar changes are needed in the markdown document.

+4
source share
1 answer

You can open the file markdownin RStudio and then use find / replace to remove the warnings. In order not to spoil the source file (in case this does not work for any reason), open the file .mdand save it with a different name. Suppose it is called my_file_copy.mdfor the example below.

With the opening, my_file_copy.mdopen the following warnings:

  • Press ctrl-F (windows) or command-F (mac) to display find / replace.
  • Add in the text box "Search" as follows: ```\n##.*\n```.
  • Leave the replace text box blank.
  • Select the "Repeat expression" selection box.
  • Click the "All" button. This will detect and delete all warnings.
  • Save my_file_copy.md.

, , rmarkdown::render("my_file_copy.md"). my_file_copy.html, .

:

rmarkdown :

---
title: "Untitled"
author: "eipi10"
date: "7/30/2017"
output: 
  html_document:
    keep_md: true
---

```{r}
library(ggplot2)
ggplot(mtcars, aes(wt,mpg)) +
  geom_point() +
  scale_x_continuous(limits=c(100,200))
```

markdown , :

# Untitled
eipi10  
7/30/2017  


```r
library(ggplot2)
ggplot(mtcars, aes(wt,mpg)) +
  geom_point() +
  scale_x_continuous(limits=c(100,200))
```

```
## Warning: Removed 32 rows containing missing values (geom_point).
```

![](Untitled_files/figure-html/unnamed-chunk-1-1.png)<!-- -->

markdown

markdown , , ``` ( ), ##. . (regex) . :

```\n##.*\n```

, , , (\n), , ##, - (.*), (\n), , . , , , . , "" .

, RStudio . , "", "Regex" . "" , . rmarkdown::render("my_file_copy.md") , html.

enter image description here

+1

Source: https://habr.com/ru/post/1682607/


All Articles