Silencing a package load message in Sweave

前端 未结 2 1225
栀梦
栀梦 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:

    <>=
    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.

提交回复
热议问题