[Rd] [Wish]: Add "..." argument to library function
Liaw, Andy
andy_liaw at merck.com
Fri Jun 4 17:28:46 CEST 2004
IMHO this should be done by the package author(s), without resorting to
changing behavior of library(). I.e., I write a function, say, startGUI(),
that does just that, and print a message in .First.lib() that tells the user
that that's what he/she should execute to startup the GUI. I believe this
is sort of how it's done in MASS on Windows (or was that MASS in S-PLUS?),
if I remember correctly...
Andy
> From: Eric Lecoutre
>
> Hello,
>
> I would find it very usefull to have the ability to load
> packages with options.
> Consider for example the SciViews package Philippe and me are
> working on.
> When loading on Windows, it automatically loads the associated GUI
> executable. It should be convenient to have an option not to
> load the exe
> but still have an access to the R functions of the package.
>
> For that, I think a simple change to 'library' would do the
> trick, which is
> to add '...' to it, as it is not used for the moment.
>
> The definition of library would then be:
>
> ----
> function (package, help, pos = 2, lib.loc = NULL,
> character.only = FALSE,
> logical.return = FALSE, warn.conflicts = TRUE, keep.source =
> getOption("keep.source.pkgs"),
> verbose = getOption("verbose"), version,...)
> #
> # Stuff removed to show which lines are changed later
> #
> .Internal(lib.fixup(loadenv, env))
> if (exists(".First.lib", mode = "function",
> envir = env,
> inherits = FALSE)) {
> firstlib <- get(".First.lib", mode = "function",
> envir = env, inherits = FALSE)
> tt <- try(firstlib(which.lib.loc, package,...))
> if (inherits(tt, "try-error"))
> if (logical.return)
> return(FALSE)
> else stop(".First.lib failed")
> }
> if (!is.null(firstlib <-
> getOption(".First.lib")[[package]])) {
> tt <- try(firstlib(which.lib.loc, package,...))
> if (inherits(tt, "try-error"))
> if (logical.return)
> return(FALSE)
> else stop(".First.lib failed")
> }
> ---------
>
> Then, in a package, the maintener can decide to include as
> many options as
> desired within his ".First.lib"
>
> ".First.lib" <- function(lib,pkg,showGUI=TRUE,useWidgets="TclTk")
> {
> if (showGUI) #
> }
>
> I am quite sure many packages could benefit from such an additionnal
> loading options
>
> Eric
> Eric Lecoutre
> UCL / Institut de Statistique
> Voie du Roman Pays, 20
> 1348 Louvain-la-Neuve
> Belgium
>
> tel: (+32)(0)10473050
> lecoutre at stat.ucl.ac.be
> http://www.stat.ucl.ac.be/ISpersonnel/lecoutre
>
> If the statistics are boring, then you've got the wrong
> numbers. -Edward
> Tufte
>
> ______________________________________________
> R-devel at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-devel
>
>
More information about the R-devel
mailing list