抑制R包命名空间中的包加载消息
我正在导入一个名为“KernSmooth”的包,希望启动消息不会出现 在我的描述文件中:抑制R包命名空间中的包加载消息,r,namespaces,R,Namespaces,我正在导入一个名为“KernSmooth”的包,希望启动消息不会出现 在我的描述文件中: Package: test Title: Test Author: Mike Description: Test Maintainer: Mike Depends: R(>= 2.10.0) Imports: KernSmooth 和我的命名空间文件: import(KernSmooth) 但当我加载包时,仍然会收到启动消息: KernSmooth 2.23 loaded Copyright M.
Package: test
Title: Test
Author: Mike
Description: Test
Maintainer: Mike
Depends: R(>= 2.10.0)
Imports: KernSmooth
和我的命名空间文件:
import(KernSmooth)
但当我加载包时,仍然会收到启动消息:
KernSmooth 2.23 loaded
Copyright M. P. Wand 1997-2009
是我唯一不在命名空间中导入它并使用它的选项
suppressMessages(require(KernSmooth))
在my R函数中避免消息?您可以在R项目的主目录中创建一个.Rprofile文件,在该文件中,您可以指示在响应某些命令时抑制消息。 下面是一个.Rprofile的示例,它禁止包的启动消息(KernSmooth): 现在,每次启动R会话时,加载包时都不会看到启动消息
您可以在R控制台上找到有关.Rprofile键入“?Startup”的更多信息,也可以查看此讨论中的.Rprofile示例:您是否查看了
suppressPackageStartupMessages
?我认为您不能在命名空间中使用它?suppressMessages确实会抑制消息,但我必须在函数中加载库。我想看看是否有办法通过名称空间来实现这一点。也许可以使用library
而不是require
。我收到一条带有require
的消息,没有一条带有library
的消息。我同意应该尊重作者的意图,但我更愿意在小插曲中注意到该软件包的使用,而不是每次加载软件包时都必须看到一个尴尬的版权。我仍然认为应该有一种方法来抑制名称空间中的消息,因此我将保留这个问题。您是否尝试过保留导入并将suppressMessages(loadNamespace('KernSmooth'))放入包中。onLoad()函数?
#This is the command you must put in your .Rprofile:
#obviously you can choose other packages instead of
#KernSmooth, as well as include other personal settings
suppressPackageStartupMessages(library(KernSmooth))