I'm trying to silence messages that explain that certain functions were masked by other packages. I have tried different combinations, but none delivered what I need.
The chunk I have is:
<<loadpkgs, echo=FALSE, warning=FALSE, message=FALSE>>=
suppressPackageStartupMessages(library(doMC))
suppressPackageStartupMessages(library(aroma.affymetrix))
suppressPackageStartupMessages(library(crlmm))
suppressPackageStartupMessages(library(snpStats))
suppressPackageStartupMessages(library(pd.genomewidesnp.6))
suppressPackageStartupMessages(library(GenomicRanges))
suppressPackageStartupMessages(library(ggbio))
@
But the output (which I hoped to be none) is (on the resulting PDF):
## Loading required package: foreach
## foreach: simple, scalable parallel programming from Revolution Analytics
## Use Revolution R for scalability, fault tolerance and more.
## http://www.revolutionanalytics.com
## Loading required package: iterators
## Loading required package: parallel
## Loading required package: R.utils
## Loading required package: R.oo
## Loading required package: R.methodsS3
## R.methodsS3 v1.5.2 (2013-10-06) successfully loaded. See ?R.methodsS3 for help.
## R.oo v1.15.8 (2013-10-10) successfully loaded. See ?R.oo for help.
##
## Attaching package: ’R.oo’
##
## The following objects are masked from ’package:methods’:
##
## getClasses, getMethods
Any thoughts on how to solve this?
Setting the parameter warn.conflicts=FALSE
in library()
as in
library(dplyr, warn.conflicts=FALSE)
should do the trick. This is particularly useful with parallel computing when potentially hundreds or more cores are loading the library.
To get rid of the "Loading ..." messages use quietly=TRUE
in the library call (and continue to use the suppressPackageStartupMessages):
suppressPackageStartupMessages(library(gdata, quietly=TRUE))
If you want to make this more compact, perhaps:
pkgs <-c('gdata', 'doMC', 'aroma.affymetrix', 'crlmm', 'snpStats',
'pd.genomewidesnp.6', 'GenomicRanges','ggbio')
for(p in pkgs) suppressPackageStartupMessages(library(p, quietly=TRUE,
character.only=TRUE))
Might be safer to do some sort of test if you are going to suppress the "loading messages".
for(p in pkgs) suppressPackageStartupMessages( stopifnot(
library(p, quietly=TRUE,
logical.return=TRUE,
character.only=TRUE)))
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