A similar question was asked previously at:
How do I suppress this output?
However, that question is only applicable to Rmarkdown code blocks. In the following case I've created a script with only the following:
library(UsingR)
I've saved the file this time as an Rscript named test.R
. However, I am using the Compile Notebook icon to compile to an html document. The resulting output is as shown:
In the previous question on the link given above, the answer was:
```{r message=FALSE}
library(UsingR)
```
which will only work in an Rmarkdown code block.
How do I suppress messages of functions more generally, for example the output of the library()
function?
You can change the call to library
so that it doesn't print any output:
library(UsingR, quietly = TRUE, warn.conflicts = FALSE)
More generally, you can suppress messages from an expression by wrapping it in a suppressMessages
:
suppressMessages(expr)
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