I need to display a disclaimer message when my package is loaded. After reading the posts
Library/package development - message when loading
Loading depending packages using .onLoad
I now have a zzz.R
file that contains only
.onLoad <- function(libname, pkgname){
packageStartupMessage('Regarding data obtained from www.retrosheet.org:\n
The information used here was obtained free of charge from
and is copyrighted by Retrosheet. Interested parties may
contact Retrosheet at "www.retrosheet.org"', domain = NULL, appendLF = TRUE)
}
I have two questions:
Do I have to call
.onLoad
somewhere? Or does that happen automatically?I'm using the
Collate
field in theDESCRIPTION
file. Doeszzz.R
need to be added to that list?
As a check, I run the following code. The package startup message appears when using install
, but not when calling library
, which I expect.
> library(devtools)
> install()
...
Reloading installed saber
Regarding data obtained from www.retrosheet.org:
The information used here was obtained free of charge from
and is copyrighted by Retrosheet. Interested parties may
contact Retrosheet at "www.retrosheet.org"
...
> detach(package:saber)
> library(saber)
Attaching package: ‘saber’
The following objects are masked _by_ ‘.GlobalEnv’:
getTeamData, relatedBatting