Re: [R] Is there a way to avoid loading dependendent packages?

From: Henrik Bengtsson <hb_at_stat.berkeley.edu>
Date: Mon, 28 Jul 2008 17:17:07 -0700

On Mon, Jul 28, 2008 at 4:29 PM, Duncan Murdoch <murdoch_at_stats.uwo.ca> wrote:
> On 28/07/2008 6:42 PM, Paul.Rustomji@csiro.au wrote:
>>
>> Hello R help list
>>
>> I have been using the smoothScatter function within the "geneplotter"
>> package to make some graphs using a Sweave Rnw script called via Rscript
>> in a DOS/Windows batch file. The Rscript will ultimately be called by a
>> web service with time-out constraints, hence things need to run as
>> swiftly as possible.
>>
>> The geneplotter package is currently loaded each time R is invoked and
>> has quite a number of dependencies, of which only one (namely Kernsmooth
>> package) appears to be necessary for the smoothScatter command to work.
>>
>> As loading all these superfluous packages (for my purposes at least)
>> takes a bit of time - is there a way to turn off the loading of
>> dependent packages so that I can only load the minimum ones I need? I
>> understand I'll be carrying the risk of missing dependencies but in this
>> case it is fairly straight forward as to why I need to do this and what
>> specific packages are needed.

Interesting that you bring up smoothScatter(); recently in a Bioconductor thread I used that function to illustrate that we as developers have a responsibility to try to minimize the package dependencies where-/whenever possible, cf. thread "[Bioc-devel] affypdnn: Request for moving "Depends" packages to "Suggests" on Tue Jul 1 23:17:16 CEST 2008
[https://stat.ethz.ch/pipermail/bioc-devel/2008-July/001640.html]. It shows all dependencies needed in order to use smoothScatter().

The issue with package dependencies is not only about loading packages but also installing packages.

>>
>> Any suggestions?
>
> Presumably everything you need is open source, so you could cut and paste
> together your own package with minimal dependencies.
>
> A big disadvantage in doing this is that it erects a large barrier to
> upgrades: if geneplotter changes, you'll have a hard time incorporating the
> changes.

...and you branching code so that we end up with to almost identical but different versions of the same function.

>
> In my opinion, you'd get better bang for the buck by buying some new
> hardware that does the same stuff faster, rather than spending the time to
> change the dependencies.

I'd say there are a few better options that everyone would gain from:

1a) Write to the maintainer and ask kindly if s/he could consider moving some package dependencies to "Suggests" and "Imports" (because those are not needed nor loaded by default). 1b) Offer your help for 1a.
2a) Suggest to have the package split up in smaller packages. Many packages grow over time and tend to loose it's original focus. 2b) Offer your help for 2a.

About smoothScatter(): I think that function should be in a light-weight package on CRAN where it can reach many more users. It's a great function but unfortunately a bit heavy/"complicated" to install.

Finally, there is indeed a workaround for not having to load geneplotter and all its dependencies (you still have to install them though). Call the function with "::" as:

x <- seq(1, 4*pi, length.out=1000);
y <- 10*sin(x) + rnorm(length(x));
geneplotter::smoothScatter(x,y);

Cheers

Henrik

>
> Duncan Murdoch
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 29 Jul 2008 - 00:22: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 Tue 29 Jul 2008 - 00:32:48 GMT.

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

list of date sections of archive