Incorporating single functions from other packages: rules and regulations?
Tim Triche, Jr. <tim.triche <at> gmail.com> writes:
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 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?
Have you tried the R Extensions manual? That doesn't quite answer the "how are they implemented" question, but it should cover "how should they be used" about as thoroughly as possible. http://obeautifulcode.com/R/How-R-Searches-And-Finds-Stuff/ may be useful as well. Beyond that, you have to look at the R language manual (if at has anything) or the source code, I think.
On Sun, Jan 13, 2013 at 7:05 AM, Dirk Eddelbuettel <edd <at> debian.org> wrote:
On 13 January 2013 at 11:16, Johannes Graumann wrote: | In a little pkg I'm developing I am in need of the functionality provided by | plotrix::listDepth. | | I am loath of having the depend on and import the whole package just for | that purpose. Step back and realize that your total R installation (including all packages) is already much bigger than the single package. And derives value from all those packages. So I would use importForm(plotrix, listDepth) in my package's NAMESPACE, and add the Imports: in the DESCRIPTION. IMHO that is the right way to do it rather than creating _stale_ and (even worse) _disconnected_ copies which will never receive updates or fixes from the _original author_ of that code. Dirk
I agree/sympathize but can also think of cases, if the function is short/simple enough, that it would actually make sense to copy it. It's a judgment call, I think. Most R packages are under sufficiently permissive licenses (plotrix is 'GPL >=2') that copying is allowed, although it would be courteous to inform/ask permission from the author(s). Ben Bolker