Silencing a package load message in Sweave

ⅰ亾dé卋堺 提交于 2019-12-01 06:01:49
Xu Wang

Try loading the package in a hide results chunk:

<<packages,results=hide>>= 
require(optmatch) 
@

If you use the knitr package, you need to quote hide:

<<packages,results='hide'>>= 
require(optmatch) 
@

Here is an R solution to your problem. The package author uses cat to print the messages to the console, rather than using standard message statements. You can intercept these messages by using sink to divert console output to a temporary file:

<<myCodeBlock, echo=FALSE>>=
zz <- tempfile()
sink(file=zz)
library(optmatch, quietly=TRUE))
unlink(zz)
@

PS. The solution by @XuWang uses only SWeave, so is clearly much more suitable in your case.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!