Situation: I want to 'extend' a package pkg1 by creating pkg2 which:
- adds a few additional methods that operate on the classes defined in pkg1 and
- re-implementing a few of the existing methods in pkg1 (e.g. changing a class's
show method).
I could just make the few additions, then instruct my colleagues to use the two packages like so:
library(pkg1); library(pkg2)
Loading pkg2 after pkg1 allows the method re-definitions to take precedence while also giving the user access to the new methods in pkg2.
But, I'd much prefer to have them just use pkg2 only, so they don't have to remember which method is in which package when they use the pkg::method notation in their code.
So, to achieve this, I want to re-export all of pkg1.
I tried this in NAMESPACE, hoping it would work:
import(pkg1)
exportPattern("^[^\\.]")
... but it does not work as hoped.
Is there any automated way to specify this in the NAMESPACE file, or am I stuck explicitly having to re-export every class, method, etc. in pkg1? (Which adds maintenance, since pkg1 might have new additions periodically that I'd have to again explicitly re-export in pkg2.)