Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't suppress messages in blogdown/knitr

Tags:

r

knitr

r-leaflet

Here is a blog post created with blogdown

The R chunk of code begins with

```{r, echo = FALSE, message = FALSE, warning = FALSE}

However, three messages appear each time I read a shapefile using sf::st_read

How do I prevent these messages from appearing in the post?

Does the answer lie in this page about knitr options?

like image 707
ixodid Avatar asked May 23 '18 03:05

ixodid


People also ask

How do I suppress a message in R?

suppressPackageStartupMessages() method in R language can be used to disable messages displayed upon loading a package in R. This method is used to suppress package startup messages.

How do you hide RMD output?

You use results="hide" to hide the results/output (but here the code would still be displayed). You use include=FALSE to have the chunk evaluated, but neither the code nor its output displayed.

How do I hide code but show output in R markdown?

include = FALSE prevents code and results from appearing in the finished file. R Markdown still runs the code in the chunk, and the results can be used by other chunks. echo = FALSE prevents code, but not the results from appearing in the finished file. This is a useful way to embed figures.


1 Answers

Moving an apparent solution initially posted in the comments to a full answer. Reasoning outlined in this meta discussion

I think st_read is just printing output normally, this won't be affected by message = FALSE or warning = FALSE. If you don't need any output from the chunk you can do results = 'hide' in the chunk options, otherwise I think you can stop it printing using st_read(..., quiet = TRUE)

Originally posted by Marius in the comments

like image 188
Zoe stands with Ukraine Avatar answered Sep 21 '22 06:09

Zoe stands with Ukraine