[R] is library loaded

Seth Falcon sfalcon at fhcrc.org
Wed Sep 14 06:28:48 CEST 2005


On 13 Sep 2005, jfox at mcmaster.ca wrote:
> packageLoaded() may well be a bad name but loadedNamespaces() won't
> detect a package without a namespace. 

Right, that's a problem.

> It therefore seemed safe to me to check the path, which would
> include both packages with and without namespaces. With respect to
> loading and attaching, I thought that library() both loaded a
> package (with or without a namespace) and attached it to the search
> path, but I must admit that I'm easily confused about these
> distinctions.

As I understand it, library(foo) will load and attach package "foo".
If foo has a namespace, some of foo's dependencies may get loaded but
not attached.  This is only possible if said dependencies also use
namespaces.

So it is possible for a package to be loaded and not attached.  In
this case, the loaded package is not visible via search(), but is
visible via loadedNamespaces() since only packages with namespaces can
be loaded and not attached.

Clear as mud?

HTH,

+ seth




More information about the R-help mailing list