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

Duncan Murdoch murdoch.duncan at gmail.com
Mon Jan 14 00:44:31 CET 2013

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

More information about the R-devel mailing list