I'm trying to run a r script from the command line, but I get warning messages when packages are loaded:
C:\Temp>Rscript myscript.r param
Warning message:
package 'RODBC' was built under R version 3.0.1
Warning message:
package 'ggplot2' was built under R version 3.0.1
Warning message:
package 'reshape2' was built under R version 3.0.1
Warning message:
package 'lubridate' was built under R version 3.0.1
Warning message:
package 'scales' was built under R version 3.0.1
I' tried to use suppressPackageStartupMessages
:
suppressPackageStartupMessages(library(RODBC))
or supressMessages
suppressMessages(library(RODBC))
but these did not suppress these messages. How to get rid of these warnings?
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. The package should be pre-installed in R, otherwise, a warning is displayed upon function call.
These are not messages but warnings. You can do:
suppressWarnings(library(RODBC))
or
suppressWarnings(suppressMessages(library(RODBC)))
to suppress both types.
I put this at the top of all my scripts and preface my library loads with it:
shhh <- suppressPackageStartupMessages # It's a library, so shhh!
Then you can load the library thusly:
shhh(library(tidyverse))
and rely on perfect silence.
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