在Sweave中沉默包加载消息

Ari*_*man 5 r sweave knitr

我正在加载optmatchSweave文档,如下所示:

<<myCodeBlock, echo=FALSE>>=
library(optmatch, quietly=TRUE)
@

You're loading optmatch, by Ben Hansen, a package for flexible
and optimal matching. Important license information:
The optmatch package makes essential use of D. P. Bertsekas
and P. Tseng's RELAX-IV algorithm and code, as well as
Bertsekas' AUCTION algorithm and code.
Bertsekas and Tseng freely permit their software to be used for
research purposes, but non-research uses, including the use of it
to 'satisfy in any part commercial delivery requirements to
government or industry,' require a special agreement with them.
By extension, this requirement applies to any use of the
fullmatch() function. (If you are using another package that has
loaded optmatch, then you will probably be using fullmatch indirectly.)
For more information, enter relaxinfo() at the command line
Run Code Online (Sandbox Code Playgroud)

正如你所看到的,我已经尝试了各种我能想到的方法来消除包装加载消息,但无济于事.我认为这是因为他们只是使用了直接cat()或类似的东西,但它非常令人讨厌.有关如何保持沉默的任何想法,以便那些阅读我的最终,美丽,LaTeXified PDF的人不必阅读RELAX-IV?

其他似乎不起作用的东西(从Andrie指向相关线程的指针):

suppressMessages(library(optmatch))
suppressPackageStartupMessages(require("optmatch"))
Run Code Online (Sandbox Code Playgroud)

我应该注意到这显然是一个R问题而不是Sweave问题,因为R中也会弹出消息.

Xu *_*ang 7

尝试在隐藏结果块中加载包:

<<packages,results=hide>>= 
require(optmatch) 
@
Run Code Online (Sandbox Code Playgroud)

如果您使用该knitr包,则需要引用hide:

<<packages,results='hide'>>= 
require(optmatch) 
@
Run Code Online (Sandbox Code Playgroud)