[R] Writing Rcmdr Plugins

G. Jay Kerns gkerns at ysu.edu
Wed Aug 20 18:48:31 CEST 2008


Dear Irina,


On Wed, Aug 20, 2008 at 12:02 PM, Irina Ursachi
<irina.ursachi at itwm.fraunhofer.de> wrote:
> Dear all,
>
> I am trying to write a plugin for the RCommander and having troubles
> understanding how to actually do that. I have read Mr. Fox's tutorial
> about writing Rcmdr plugins and though.... it seems to me that some
> steps are missing.  I would like to know, whether there are some
> Commands which generate a plugin package out of a given library. Or do
> we just have to attach the .First.lib function and the menus.txt data to
> the library? Out of the RcmdrPlugin.TeachingDemos example I could see,
> that one of the differences between the plugin and the library, is the
> fact that the plugin package also contains the "etc" subdirectory... so
> I suppose my plugin package should contain one too, right?
> The way I was trying to build my plugin package (and it didn't work )
> was: I installed Rcmdr, the latest version locally, in a folder named
> "Rlib". There is where I also installed my library and trying to use the
> "require" command to load it into R Commander. What I don't understand,
> is how to build the RcmdrPlugin.*?
> I would really appreciate, if somebody could help me with that, or maybe
> just recommend me a tutorial.
>
> Best regards,
> Irina Ursachi.
>

In general, you can read the R-manuals (in particular, the "Writing R
Extensions" one) to make sure that you have all of absolutely
necessary components (a DESCRIPTION, an /R directory, all of the
required documentation, etc.)

That being said, the basic format of an RcmdrPlugin is:

The /R directory:  this is where you put all of the Tcl/Tk functions
for your menus that you want to add.  In addition, any extra functions
that you wrote that are new should go in here.  You will need in here
the .First.lib function that John mentioned in his article, in the
format that he suggested.

The /man directory:  this has all of the .Rd help files.   One of
these files will likely be titled something like
"RcmdrPlugin.foo-internal.Rd".  This is where you will put aliases to
many of the functions that are 'internal' in the sense that they are
not to be called by the user.

The /inst directory:  in here you will need to put a file "menus.txt".
 John Fox's article gives you lots of details about how to set it up
correctly.  You only need to include lines for the menus that you are
specifically adding.  And now with Rcmdr_1.4-0, you can include lines
for menus that you prefer _not_ to appear (this really helps with
making the menus less cluttered when multiple plugins are loaded).

The /data directory: optional.  Do you want to include data with your plugin?

Your DESCRIPTION file should be set up as the article recommends, with
the DEPENDS argument showing at least Rcmdr 1.3.0 (and you would be
advised to go with Rcmdr 1.4.0).  See the article about the details of
DESCRIPTION.

There are a lot more things that you can do;  please see the manuals
for details.  But the above has the bare essentials for a RcmdrPlugin
(I don't believe that I am forgetting anything.)

Once you have those essential parts, then the RcmdrPlugin is built and
installed in exactly the same way as any other R package (again, see
the manuals....  I see an "R CMD build" in your future...  :-).  There
are many, many messages on the R-help archive to help you for your
operating system, and many people have written online tutorials.

Perhaps the best advice is to download the source code
RcmdrPlugin.xxxxx.tar.gz from CRAN (e.g. RcmdrPlugin.IPSUR), extract
the archive, and take a look at how other people have done it.

I hope that this helps, and good luck!  :-)

Jay




***************************************************
G. Jay Kerns, Ph.D.
Associate Professor
Department of Mathematics & Statistics
Youngstown State University
Youngstown, OH 44555-0002 USA
Office: 1035 Cushwa Hall
Phone: (330) 941-3310 Office (voice mail)
-3302 Department
-3170 FAX
E-mail: gkerns at ysu.edu
http://www.cc.ysu.edu/~gjkerns/



More information about the R-help mailing list