Disable messages upon loading a package
Just use suppressMessages()
around your library()
call:
edd@max:~$ R
R version 2.14.1 (2011-12-22)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-pc-linux-gnu (64-bit)
[...]
R> suppressMessages(library(ROCR))
R> # silently loaded
R> search()
[1] ".GlobalEnv" "package:ROCR" # it's really there
[3] "package:gplots" "package:KernSmooth"
[5] "package:grid" "package:caTools"
[7] "package:bitops" "package:gdata"
[9] "package:gtools" "package:stats"
[11] "package:graphics" "package:grDevices"
[13] "package:utils" "package:datasets"
[15] "package:methods" "Autoloads"
[17] "package:base"
R>
library(ROCR, quietly = TRUE)
might be a more elegant option.
Use suppressPackageStartupMessages
, see the answer by MehradMahmoudian. For completeness, adding here examples of usage:
For one library, use suppressPackageStartupMessages(...)
, for example:
suppressPackageStartupMessages(library(ggplot2))
For multiple libraries, use suppressPackageStartupMessages({...})
, for example:
suppressPackageStartupMessages({
library(ggplot2)
library(ggdendro)
})
SEE ALSO:
Suppress package startup messages
Dirk's answer suppresses all messages and is not specific to messages that is generated while loading packages.
The more accurate solution to the asked question is:
suppressPackageStartupMessages(library(THE_PACKAGE_NAME))
A bit more detailed explanation can be found here