Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111
> -----Original Message-----
> From: Prof Brian Ripley [mailto:ripley at stats.ox.ac.uk]
> Sent: Monday, April 04, 2011 3:41 PM
> To: Greg Snow
> Cc: R-devel at r-project.org
> Subject: Re: [Rd] Use keep.source for function in package with lazy
> loading
>
> On Mon, 4 Apr 2011, Greg Snow wrote:
>
> > I have a function in one of my packages that I would like to print
> > using the original source rather than the deparse of the function.
> > The package uses lazy loading and the help page for library (under
> > keep.source) says that keep.source does not apply to packages that
> > use lazy loading and that whether those functions keep the source
> > depends on when they are installed.
>
> Not quite: it is says it is 'determined when it is installed'.
>
> For a package that does not use lazy loading, what is installed is a
> file of R code. When library() loads such a package, it sources() the
> R code, and at that point has the option to keep the source or not
> (for that R session).
>
> For a package which uses lazy loading, the source()ing happens when
> the package is installed: the objects created are then dumped into a
> database. Whether the source attribute is retained at that point
> depends on the setting of the option "keep.source.pkgs". So if you can
> arrange to install the package with that option set to true, in
> principle (and in my experiments) the source attributes are retained.
>
> The easiest way to do this would seem to be to set the environment
> variable R_KEEP_PKG_SOURCE to "yes" whilst installing the package.
>
> > This package is on R-forge and is being built there (and will
> > eventually be used to submit the next version of the package to
> > CRAN).
> >
> > I am not sure what the help means by 'installed', I have set the
> > options to keep the source to TRUE before calling install.package,
> > but that does not seem to work.
>
> I presume you mean keep.source.pkgs, not keep.source? That needs to
> be set in the process which is installing the package:
> install.packages() calls R CMD INSTALL in a separate process.
>
> > Is there a way to "strongly encourage" the source to be kept for
> > this function (or the entire package)?
> >
> > Thanks,
> >
> > --
> > Gregory (Greg) L. Snow Ph.D.
> > Statistical Data Center
> > Intermountain Healthcare
> > greg.snow at imail.org
> > 801.408.8111
>
> --
> Brian D. Ripley, ripley at stats.ox.ac.uk
> Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
> University of Oxford, Tel: +44 1865 272861 (self)
> 1 South Parks Road, +44 1865 272866 (PA)
> Oxford OX1 3TG, UK Fax: +44 1865 272595