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

2010-11-16 Thread Berwin A Turlach
G'day Hadley, On Tue, 16 Nov 2010 07:35:09 -0600 Hadley Wickham wrote: > > Well, as the part of "Writing R Extensions" that Martin quoted > > states, the normal search path is part of the search path used by > > packages with name spaces.  So if you attach another package via > > library(), the

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

2010-11-16 Thread Hadley Wickham
>> Ah, my mistake was assuming that the package namespace and environment >> were the same thing. >> >> Interestingly the namespace is dynamic: > > Not sure what you mean with this.  Section 1.6 of "Writing R > Extensions" explicitly states: > >        Name spaces are @emph{sealed} once they are lo

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

2010-11-16 Thread Berwin A Turlach
G'day Hadley, On Mon, 15 Nov 2010 19:45:30 -0600 Hadley Wickham wrote: > > 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 the

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

2010-11-15 Thread Mark Leeds
Hi Duncan: Luke's article is in the June, 2003 edition of R-news On Mon, Nov 15, 2010 at 8:43 PM, Duncan Murdoch wrote: > Hadley Wickham wrote: > >> Hi all, >> >> I'm trying to understand how the search path and namespaces interact. >> For example, take the devtools package which suggests the te

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

2010-11-15 Thread Hadley Wickham
> 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(

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

2010-11-15 Thread Duncan Murdoch
Hadley Wickham wrote: Hi all, I'm trying to understand how the search path and namespaces interact. For example, take the devtools package which suggests the testthat package. Here's what the search path looks like after I load each of those packages: Luke Tierney wrote up a nice description

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

2010-11-15 Thread Martin Morgan
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

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

2010-11-15 Thread Hadley Wickham
> 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:t

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

2010-11-15 Thread Hadley Wickham
> With a small risk of being incorrect (and the chance of learning > something new), I'll give it a try: > > A search for a functions/objects/... that is not in the same package > environment is done in the order that the search() path gives.  The > exception to this iff your package has a namespac

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

2010-11-15 Thread Henrik Bengtsson
On Mon, Nov 15, 2010 at 3:26 PM, Hadley Wickham wrote: > Hi all, > > I'm trying to understand how the search path and namespaces interact. > For example, take the devtools package which suggests the testthat > package.  Here's what the search path looks like after I load each of > those packages:

[Rd] Trying to understand the search path and namespaces

2010-11-15 Thread Hadley Wickham
Hi all, I'm trying to understand how the search path and namespaces interact. For example, take the devtools package which suggests the testthat package. Here's what the search path looks like after I load each of those packages: > library(devtools) > search() [1] ".GlobalEnv""package:d