From ligges at statistik.uni-dortmund.de  Mon May 28 17:42:02 2007
From: ligges at statistik.uni-dortmund.de (Uwe Ligges)
Date: Mon, 28 May 2007 17:42:02 +0200
Subject: [Rd] How to correctly write a package?
In-Reply-To: <10837938.post@talk.nabble.com>
References: <10837938.post@talk.nabble.com>
Message-ID: <465AF84A.4070007@statistik.uni-dortmund.de>



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

a) R CMD build ac9
b) R CMD INSTALL ac9_01.tar.gz
c) 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.



[Rd] How to correctly write a package?
Uwe Ligges