From murdoch.duncan at gmail.com  Tue Nov 16 02:43:44 2010
From: murdoch.duncan at gmail.com (Duncan Murdoch)
Date: Mon, 15 Nov 2010 20:43:44 -0500
Subject: [Rd] Trying to understand the search path and namespaces
In-Reply-To: <AANLkTin090pRti8dXknLKtpFmUmmvRsAz6a0V2mx5iOM@mail.gmail.com>
References: <AANLkTin090pRti8dXknLKtpFmUmmvRsAz6a0V2mx5iOM@mail.gmail.com>
Message-ID: <4CE1E1D0.2010200@gmail.com>

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 of this a few years ago.  It's 
either on developer.r-project.org, or in an old issue of R News.

Duncan Murdoch

> 
>> library(devtools)
>> search()
>  [1] ".GlobalEnv"        "package:devtools"  "package:stats"
>  [4] "package:graphics"  "package:grDevices" "package:utils"
>  [7] "package:datasets"  "package:methods"   "Autoloads"
> [10] "package:base"
>> library(testthat)
>> search()
>  [1] ".GlobalEnv"        "package:testthat"  "package:devtools"
>  [4] "package:stats"     "package:graphics"  "package:grDevices"
>  [7] "package:utils"     "package:datasets"  "package:methods"
> [10] "Autoloads"         "package:base"
> 
> My question is this: when I execute the test function in devtools
> function it calls the the test_package function in the testthat
> package - but that function is located higher up the search path - how
> does R find it?
> 
> (I ask this question because I'm trying to simulate package loading
> from within R to simplify the development cycle, but something is
> missing in my knowledge of namespaces, and so I have the devel
> versions of my packages can't access packages that are loaded after
> they are)
> 
> Hadley
>



[Rd] Trying to understand the search path and namespaces
Duncan Murdoch