Re: [Rd] Use keep.source for function in package with lazy loading

From: Greg Snow <Greg.Snow_at_imail.org>
Date: Mon, 18 Apr 2011 14:01:25 -0600

Thanks, that looks great.

Looking for other options I found a way to do something I had not originally considered, but like even better now. My original purpose on this was a string with some tabs in it that when the function was viewed without the source were turned into "\t" which looked ugly and partly countered what I was trying to do.

My current attempt can be seen by looking at the 'petals' function in the development version of the TeachingDemos package on R-Forge. It works great on windows, now I just need to find some people to test it on Mac and Linux to make sure that everything is doing what it should there.

-- 
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: Sunday, April 10, 2011 4:52 AM
> To: Greg Snow
> Cc: R-devel_at_r-project.org
> Subject: RE: [Rd] Use keep.source for function in package with lazy
> loading
>
> R-devel now has a KeepSource DESCRIPTION field to accomplish what I
> think you are seeking.
>
> On Tue, 5 Apr 2011, Greg Snow wrote:
>
> > Prof. Ripley,
> >
> > Thanks for the explanation. I had set both keep.source and
> keep.source.packages to TRUE for my experiments, but had not realized
> that a new R process would be involved, so did not try the
> environmental variable approach.
> >
> >> From what you say below, I don't think I am going to accomplish what
> I wanted, since I want the source to show for users other than myself
> and there does not seem to be a reasonable way to change the users
> environment before installing my package (that is getting a bit too big
> brother to even think about). I was hoping that there might be some
> switch somewhere that I had missed that would say keep the source for
> this function even though the default is not to. But, it does not look
> like there is anything like that, and it is not worth implementing just
> for my one little use.
> >
> > Hmm, maybe I can set the source manually using .onAttach, I'll have
> to experiment some more.
> >
> > Thanks,
> >
> > --
> > 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
> >
>
> --
> 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
______________________________________________ R-devel_at_r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Mon 18 Apr 2011 - 20:04:01 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 Mon 18 Apr 2011 - 22:00:48 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.

list of date sections of archive