Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
355 views
in Technique[技术] by (71.8m points)

r - How to suppress warning messages when loading a library?

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?

question from:https://stackoverflow.com/questions/18931006/how-to-suppress-warning-messages-when-loading-a-library

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

These are not messages but warnings. You can do:

suppressWarnings(library(RODBC))

or

suppressWarnings(suppressMessages(library(RODBC)))

to suppress both types.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...