Hello all,
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.
Kind regards,
Yannick
Hello all,
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.
Kind regards,
Yannick
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.
One convention is that people will frequently put these commands in a separate zzz.R
file, which is just used for package related code.
Quick points:
if your package has a NAMESPACE, then .onLoad()
is where you do this
if your package does not have NAMESPACE, then .First.lib()
is where you do this
either way, use packageStartupMessage()
instead of cat()
so that users have a choice of suppressing this.