From murdoch.duncan at gmail.com  Mon Jan 14 00:44:31 2013
From: murdoch.duncan at gmail.com (Duncan Murdoch)
Date: Sun, 13 Jan 2013 18:44:31 -0500
Subject: [Rd] Incorporating single functions from other packages: rules
 and regulations?
In-Reply-To: <CAC+N9BUFa3j2AatshUF61Vy8B7_DaxEEMDUVnOtaqC7irP0p7A@mail.gmail.com>
References: <kctqel$eoh$1@ger.gmane.org>
	<20722.52551.510334.990311@max.nulle.part>
	<CAC+N9BUFa3j2AatshUF61Vy8B7_DaxEEMDUVnOtaqC7irP0p7A@mail.gmail.com>
Message-ID: <50F346DF.8020301@gmail.com>

On 13-01-13 3:44 PM, Tim Triche, Jr. wrote:
>   a n00b question:
>
> if I call importFrom(IRanges, ranges) in my NAMESPACE file, that works
> great.
> but if  I call
>
> R> importFrom(IRanges, ranges)
> ## Error: could not find function "importFrom"
>
> well, that doesn't work great.

The NAMESPACE file is parsed as R code, but you should think of it as a 
bunch of declarations, not as something executable.  There's no 
importFrom() function.

If you want to do something similar at run-time, you could use

ranges <- IRanges::ranges

This creates a copy of the function you want in the current environment.


The closest thing I can find in base is
>
> base:::importIntoEnv
>
> which helpfully informs me that it is one of several
>
> Internal namespace support functions.  Not intended to be called directly.
>
>
> Where's the best place to learn about how namespaces and import/export
> facilities (particularly in R-3.0) are implemented?

Probably the source code.

Duncan Murdoch



[Rd] Incorporating single functions from other packages: rules and regulations?
Duncan Murdoch