库/包开发 - 加载时的消息 [英] Library/package development - message when loading

查看:13
本文介绍了库/包开发 - 加载时的消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在用户加载 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.

这篇关于库/包开发 - 加载时的消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆