Henrik Bengtsson
2015-May-09 20:57 UTC
[Rd] PATCH: library(..., quietly=TRUE) still outputs "Loading required package: ..." (forgot to pass down 'quietly')
Calling library(..., quietly=TRUE) may still output: Loading required package: <other pkg> in some cases, e.g.> library("R.utils", quietly=TRUE)Loading required package: R.methodsS3 [...] I traced this to base:::.getRequiredPackages2(), which forgets to pass 'quietly' to an internal library() call: if (!attached) { if (!quietly) packageStartupMessage(gettextf("Loading required package: %s", pkg), domain = NA) library(pkg, character.only = TRUE, logical.return = TRUE, lib.loc = lib.loc) || stop(gettextf("package %s could not be loaded", sQuote(pkg)), call. = FALSE, domain = NA) } It's from that library() call the message is generated. Here's a patch: $ svn diff src\library\base\R\library.R Index: src/library/base/R/library.R ==================================================================--- src/library/base/R/library.R (revision 68345) +++ src/library/base/R/library.R (working copy) @@ -871,7 +871,7 @@ packageStartupMessage(gettextf("Loading required package: %s", pkg), domain = NA) library(pkg, character.only = TRUE, logical.return = TRUE, - lib.loc = lib.loc) || + lib.loc = lib.loc, quietly = quietly) || stop(gettextf("package %s could not be loaded", sQuote(pkg)), call. = FALSE, domain = NA) } I can submit it via http://bugs.r-project.org/ if preferred. Thanks, Henrik
Martin Maechler
2015-May-11 15:53 UTC
[Rd] PATCH: library(..., quietly=TRUE) still outputs "Loading required package: ..." (forgot to pass down 'quietly')
>>>>> Henrik Bengtsson <henrik.bengtsson at ucsf.edu> >>>>> on Sat, 9 May 2015 13:57:12 -0700 writes:> Calling library(..., quietly=TRUE) may still output: > Loading required package: <other pkg> > in some cases, e.g. >> library("R.utils", quietly=TRUE) > Loading required package: R.methodsS3 > [...] > I traced this to base:::.getRequiredPackages2(), which forgets to pass > 'quietly' to an internal library() call: > if (!attached) { > if (!quietly) > packageStartupMessage(gettextf("Loading required package: %s", > pkg), domain = NA) > library(pkg, character.only = TRUE, logical.return = TRUE, > lib.loc = lib.loc) || stop(gettextf("package %s could not be loaded", > sQuote(pkg)), call. = FALSE, domain = NA) > } > It's from that library() call the message is generated. > Here's a patch: > $ svn diff src\library\base\R\library.R > Index: src/library/base/R/library.R > ================================================================== > --- src/library/base/R/library.R (revision 68345) > +++ src/library/base/R/library.R (working copy) > @@ -871,7 +871,7 @@ > packageStartupMessage(gettextf("Loading required package: %s", > pkg), domain = NA) > library(pkg, character.only = TRUE, logical.return = TRUE, > - lib.loc = lib.loc) || > + lib.loc = lib.loc, quietly = quietly) || > stop(gettextf("package %s could not be loaded", sQuote(pkg)), > call. = FALSE, domain = NA) > } > I can submit it via http://bugs.r-project.org/ if preferred. No. It's easier that way -- already in the R-devel sources, thank you Henrik. Martin > Thanks, > Henrik
Seemingly Similar Threads
- Suggested Patch: Library returns matching installed packages when typo present
- R-2.15.1 CMD CHECK output: "Call Sequence"
- SUGGESTION: Settings to disable forked processing in R, e.g. parallel::mclapply()
- reducing redundant work in methods package
- Bug in loadNamespace?