[Rd] Trying to understand the search path and namespaces
Martin Morgan
mtmorgan at fhcrc.org
Tue Nov 16 02:27:34 CET 2010
On 11/15/2010 04:56 PM, Hadley Wickham wrote:
>> Well, that's what I thought too. But:
>>
>> parents <- function(x) {
>> if (identical(x, emptyenv())) return()
>> c(environmentName(x), parents(parent.env(x)))
>> }
>>> parents(as.environment("package:devtools"))
>> [1] "package:devtools" "package:methods" "Autoloads" "base"
>>
>> And package:testthat isn't listed there. (But Autoloads is suggestive...)
>
> Hmmm, autoloads isn't it:
>
>> parent.env(parent.env(as.environment("package:devtools")))
> <environment: 0x100951f88>
> attr(,"name")
> [1] "Autoloads"
>> ls(parent.env(parent.env(as.environment("package:devtools"))))
> character(0)
1.6 of Writing R Extensions says
Note that adding a name space to a package changes the search strategy.
The package name space comes first in the search, then the imports, then
the base name space and then the normal search path.
I'm not sure of the details, but I think
parents(getNamespace("devtools"))
will give you what you want, with the gory details in loadNamespace
makeNamespace
Martin
>
> Hadley
>
--
Computational Biology
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109
Location: M1-B861
Telephone: 206 667-2793
More information about the R-devel
mailing list