Silencing a package load message in Sweave

前端 未结 2 1202
栀梦
栀梦 2021-01-13 03:54

I\'m loading optmatch in a Sweave document as follows:

<>=
library(optmatch, quietly=TRUE)
@

You\'re loadi         


        
相关标签:
2条回答
  • 2021-01-13 04:18

    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.

    0 讨论(0)
  • 2021-01-13 04:22

    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) 
    @
    
    0 讨论(0)
提交回复
热议问题