[Rd] Shouldn't "Loading" be "Attaching" when referring to library() calls?
Michael Chirico
ch|r|com @end|ng |rom goog|e@com
Mon Jan 9 21:25:46 CET 2023
require() and library() both emit this message immediately before
running library():
"Loading required package: %s"
https://github.com/r-devel/r-svn/blob/4198a2941b702d965bb2374c2b908f48c369f40a/src/library/base/R/library.R#L967-L968
https://github.com/r-devel/r-svn/blob/4198a2941b702d965bb2374c2b908f48c369f40a/src/library/base/R/library.R#L684-L685
Shouldn't "Loading" be "Attaching" instead?
My understanding is "a package is loaded" is equivalent to
"isNamespaceLoaded()", i.e., loadNamespace() was run. And that "a
package is attached" is equivalent to "pkg %in% .packages()", i.e.,
library(pkg) was run.
Is the terminology not so precise?
There's certainly ambiguity in the internal variable names referenced
above -- in require, we see
loaded <- paste0("package:", package) %in% search()
https://github.com/r-devel/r-svn/blob/4198a2941b702d965bb2374c2b908f48c369f40a/src/library/base/R/library.R#L680
Whereas in library() [via .getRequiredPackages2()] we see
attached <- paste0("package:", pkg) %in% search()
https://github.com/r-devel/r-svn/blob/4198a2941b702d965bb2374c2b908f48c369f40a/src/library/base/R/library.R#L931
Mike C
More information about the R-devel
mailing list