问题描述
当用户加载library(myCustomLibrary)
时,是否有任何显示消息的方式?加载后,我想显示一条消息,告诉用户如何运行所有测试功能.
is there any way to display a message when a user loads library(myCustomLibrary)
?Upon loading, I want to display a message that tells the user how to run all the test functions.
推荐答案
是.加载包时,可以使用.onLoad
,.onAttach
或.First.lib
函数执行所需的任何操作.我建议查看这些功能的帮助.您可以将.onLoad
与命名空间结合使用,而将.First.lib
与命名空间结合使用.
Yes. You can use the .onLoad
, .onAttach
, or .First.lib
functions to do whatever you want when the package is loaded. I suggest looking at the help for those functions. You would use .onLoad
with a namespace, and .First.lib
without.
一个约定是,人们经常将这些命令放在单独的zzz.R
文件中,该文件仅用于与软件包相关的代码.
One convention is that people will frequently put these commands in a separate zzz.R
file, which is just used for package related code.
这篇关于库/软件包开发-加载时的消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!