Skip to content
Back to formatted view

Raw Message

Message-ID: <50F346DF.8020301@gmail.com>
Date: 2013-01-13T23:44:31Z
From: Duncan Murdoch
Subject: Incorporating single functions from other packages: rules and regulations?
In-Reply-To: <CAC+N9BUFa3j2AatshUF61Vy8B7_DaxEEMDUVnOtaqC7irP0p7A@mail.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