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?
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.
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.
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.
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 bymessage = FALSE
orwarning = FALSE
. If you don't need any output from the chunk you can doresults = 'hide'
in the chunk options, otherwise I think you can stop it printing usingst_read(..., quiet = TRUE)
Originally posted by Marius in the comments
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With