[R] updating contents of a package

Tobias Verbeke tobias.verbeke at openanalytics.be
Sun Feb 8 11:16:39 CET 2009


Hi Markus,

> I read through the "Writing R Extensions" document and am able to now create
> my own packages/libraries which so far are just well documented collections
> of my own R functions. I use package.skeleton() and the tools package to
> build these packages.
> However, it is not clear to me how to modify and update a package after its
> initial creation. How do you elegantly update e.g. the old help file when
> one added an argument to a function ? How do you keep most of the existing
> package structure when implementing incremental changes ?

Generally speaking you will have your package in a directory we will 
call PKG_ROOT here, with (more or less) the following structure

PKG_ROOT
       `- inst
       `- man
       `- R
       `- DESCRIPTION
       `- NAMESPACE


If you want to update the package, you edit the help files, the R files,
etc. in their respective folders and when you're finished you can build, 
check and/or install the package using

R CMD build PKG_ROOT
R CMD check PKG_ROOT
R CMD INSTALL PKG_ROOT

or what is appropriate for your platform. To build
a Windows binary package, e.g. you will need

R CMD INSTALL --build PKG_ROOT

For this to work you will need R to work from
the commandline (add it to your PATH). On Windows
you also need to have installed the R
Windows Toolset provided by Duncan Murdoch at

http://www.murdoch-sutherland.com/Rtools/

If you would like to keep track of the changes
from package version to package version, you
can maintain a NEWS or ChangeLog file in the
inst/ package directory.

HTH,
Tobias




More information about the R-help mailing list