Display instruction text on package load

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Display instruction text on package load

Thomas J. Leeper
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

--
Thomas J. Leeper

PhD Candidate, ABD
Department of Political Science
Northwestern University
[hidden email]
http://www.thomasleeper.com

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Display instruction text on package load

Dirk Eddelbuettel

On 7 April 2012 at 16:27, 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.

Start with

      help(packageStartupMessage)
      help(.onLoad)

and also peruse the list archives here---you probably want this in your
.onLoad() function.

Maybe some of the packages interfacing Google's APIs and webservices have an
example.

Dirk

--
R/Finance 2012 Conference on May 11 and 12, 2012 at UIC in Chicago, IL
See agenda, registration details and more at http://www.RinFinance.com

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Display instruction text on package load

Brian Ripley
In reply to this post by Thomas J. Leeper
On 07/04/2012 22:27, 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
>

?.onAttach
?packageStartupMessage

(You could also look at the sources for package Zelig, but actually it
is a poor example since it ignores the arguments to .onAttach, and
wastes time calling packageDescription() twice.)

--
Brian D. Ripley,                  [hidden email]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Display instruction text on package load

Duncan Murdoch-2
In reply to this post by Thomas J. Leeper
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

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Display instruction text on package load

Thomas J. Leeper
In reply to this post by Thomas J. Leeper
Great! I will look into .onAttach, .onLoad, and packageStartupMessage.

Thanks so much!

-Thomas

On Sat, Apr 7, 2012 at 4:27 PM, Thomas J. Leeper <[hidden email]>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
>
> --
> Thomas J. Leeper
>
> PhD Candidate, ABD
> Department of Political Science
> Northwestern University
> [hidden email]
> http://www.thomasleeper.com
>
>


--
Thomas J. Leeper

PhD Candidate, ABD
Department of Political Science
Northwestern University
[hidden email]
http://www.thomasleeper.com

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel