Re: [Rd] Trying to understand the search path and namespaces

From: Martin Morgan <mtmorgan_at_fhcrc.org>
Date: Mon, 15 Nov 2010 17:27:34 -0800

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

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Tue 16 Nov 2010 - 01:35:30 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 16 Nov 2010 - 02:10:21 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive