[R] Unintended loading of package:datasets

Berwin A Turlach berwin at maths.uwa.edu.au
Mon May 11 03:52:19 CEST 2009


G'day David,

On Sun, 10 May 2009 17:17:38 -0400
"David A Vavra" <davavra at verizon.net> wrote:

> The dataset package is being loaded apparently by one of the packages
> that I am using. The loading of the datasets takes a long time and I
> would like to eliminate it. I thought the datasets were effectively
> examples so don't understand why they would be required at all.
> 
> 1) How can I determine what is causing the datasets to be loaded?

help(options)
and then read the part on "defaultPackages"

> 2) How can I stop them from doing so?

Create an appropriate .Rprofile.  R-DownUnder had long time ago a
discussion on what people put into their .Rprofile,  and Bill
Venables' .Rprofile seem to contain the following snippet:

### puts four more packages on to the default
### search path.  I use them all the time
local({
  old <- getOption("defaultPackages")
  options(defaultPackages = c(old, "splines",
            "lattice", "mgcv", "MASS"))
}) 
 
> I am using the following:
> 
> Rpart, grDevices, graphics, stats, utils, methods, base
> There is also an environment named 'Autoloads'

Rpart??  Or rpart??  I know of a package with the latter name but not
the former, and R is case sensitive.

So you may try:

local({
  options(defaultPackages=c("rpart", "grDevices", "graphics", "stats",
           "utils", "methods")
})

FWIW, note that for command XXX, help(XXX) will give you a help page
that has usually some example code at the end, that code can be run by
example(XXX).  Typically, such example code is using data sets from
the datasets package; so if you do not load it, the example() command
might not work anymore for some functions.  

Don't complain if your R installation doesn't work anymore if you mess
around with defaultPackages, in particular if you remove packages that
are usually in the default of defaultPackages. :)

And I agree with Rolf (Turner), it is hard to believe that the
datasets package would produce a noticeable delay on start-up; for me
it also loads instantaneously.  I guess that your problem is more
along David's (Winsemuis) guess. 

Cheers,

	Berwin




More information about the R-help mailing list