Using .onLoad to create new menus when a package is loaded

33 views
Skip to first unread message

Helios De Rosario

unread,
Jan 9, 2012, 9:58:02 AM1/9/12
to Deducer
The Deducer wiki gives an example of using the function .First.lib in
a package source, in order to automatically create new menus in JGR or
Windows RGUI when the package is loaded:

http://www.deducer.org/pmwiki/index.php?n=Main.Development#wiuiap

However, according to the manual for writing R extensions (http://
cran.r-project.org/doc/manuals/R-exts.html), .First.lib should be
replaced by .onLoad if a namespace is going to be defined, and
defining namespaces is actually mandatory in R-2.14.0 or later. It is
still possible to write a package without the NAMESPACE file and
a .First.lib() function, because "R CMD build" or "R CMD install"
automatically do the necessary changes to define the namespace. But
this may change in the future.

The problem is that just changing the function name (".onLoad" instead
of ".First.lib") seems problematic. There apparently is some problem
with the definition of imports and exports for the namespace, because
some of the functions and variables used within the .onLoad are not
found.

So, the code of .onLoad should be different, or the package author
should include some directives in the NAMESPACE file to handle this
issue. Can anybody help with this?

Thanks
Helios

Ian Fellows

unread,
Jan 9, 2012, 3:44:38 PM1/9/12
to ded...@googlegroups.com
Feel free to update the documentation. See DeducerExtras or
DeducerPlugInExample to see how .onLoad is used.

Ian

Helios De Rosario

unread,
Jan 9, 2012, 7:34:46 PM1/9/12
to Deducer
Thanks for the suggestion. That documentation section is already
updated. I hope the changes are correct.

Helios

On 9 ene, 21:44, Ian Fellows <ifell...@gmail.com> wrote:
> Feel free to update the documentation. See DeducerExtras or
> DeducerPlugInExample to see how .onLoad is used.
>
> Ian
>
> On Mon, Jan 9, 2012 at 6:58 AM, Helios De Rosario
>
Reply all
Reply to author
Forward
0 new messages