Re: [Rd] How to correctly write a package?

From: Uwe Ligges <ligges_at_statistik.uni-dortmund.de>
Date: Mon, 28 May 2007 17:42:02 +0200

Vladimir Eremeev wrote:
> I am writing a package.
>
> Please, study the sequence of my actions below, and comment, what's
> incorrect.
> The package contains pure R code.
>
> 1. At the one level up from the package directory, from the system command
> prompt:
> R CMD build --binary ac9
>
> This produces the file ac9_0.1.zip (The package name is ac9, and the
> package's DESCRIPTION file says its version is 0.1)
>
> 2. Then I run Rgui in the other directory and "Install package(s) from local
> zip files"

I'd rather do

  1. R CMD build ac9
  2. R CMD INSTALL ac9_01.tar.gz
  3. If a) and b) worked: R CMD check ac9_01.tar.gz

> 3. Issue the following commands in the command of Rgui from step 2 :
>
> library(ac9)
> [calls to functions from the package]
>
> 4. If I see errors, I quit Rgui from step 2, then change (hopefully)
> properly the source package code, and
> go to step 1.
>
> What would happen if I don't quit Rgui from the step 2?
> Would it reload the new function definitions?

Depends on some details on the package. In principle, you can detach() the package and load it later without closing R in the meantime. Of course, when closing R you are on the very safe side.

> Is there any other methods to refine a packaged code, which experienced
> package writers use in their routine work?

Some of the "experienced package writers" probably use svn, cvs or some other version control system and so have the sources therein. They are simply updating the source code directly without using package.skeleton() after they once used it for a first skeleton of the package.

Uwe Ligges

> I have created package source using package.skeleton, and have documented
> the functions.
> Updating of the function body and re-use of the package.skeleton with
> force=TRUE overwrites the documentation files. This disallows often use of
> this function, or requires keeping the backup copy of the package sources.



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Mon 28 May 2007 - 15:45:20 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 29 May 2007 - 09:33:53 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.