[Rd] Display instruction text on package load

Duncan Murdoch murdoch.duncan at gmail.com
Sun Apr 8 15:07:59 CEST 2012


On 12-04-07 5:27 PM, Thomas J. Leeper wrote:
> I'm currently working on a new package for R that interfaces with an API.
> Most of the package's functionality requires users to supply an access key
> that allows the package to work with the API. I want to display text
> immediately upon loading the package that instructs/reminds users to enter
> their access key before attempting to do anything (as the package won't
> really work without it). I've searched the relevant help files for creating
> packages but haven't been able find anything about how to do this. As an
> example, library(Zelig) does what I'm trying to achieve.
>
> Thanks for your help! And sorry if there's an obvious answer to this that I
> am oblivious to.
> -Thomas
>

You can create functions that run when your package is attached (put 
onto the search list) or loaded (loaded into memory, possibly because 
another package is using it).  You can read about these in the "Load 
Hooks" section of the Writing R Extensions manual, or the ?.onLoad help 
page.

Duncan Murdoch



More information about the R-devel mailing list