Dr Gregory Jefferis
2012-Jul-06 10:57 UTC
[Rd] depends/suggests when making a new generic to override a function in a user package
Dear R developers,
I would like to add a new S3 generic to override a function in a user package,
specifically:
STAR::as.repeatedTrain
I have followed the recommendation here:
http://cran.r-project.org/doc/manuals/R-exts.html#Adding-new-generics
doing this:
as.repeatedTrain<-function(x,...){
UseMethod("as.repeatedTrain")
}
as.repeatedTrain.default<-function(x,...) {
STAR::as.repeatedTrain(x)
}
but the question now arises, how do I make sure that my as.repeatedTrain generic
function is used in preference to STAR's. If my package suggests STAR, then
STAR will likely be loaded afterwards and my generic will get clobbered. So at
the moment I have made my package depend on STAR rather than suggest it. However
I will only occasionally use STAR, and it is quite a big package with a number
of dependencies and I would prefer to avoid this. Is there another approach? I
assume this isn't a problem for a non-generic in a base package because they
are loaded first.
Many thanks for any suggestions,
Greg Jefferis.
--
Gregory Jefferis, PhD
Division of Neurobiology
MRC Laboratory of Molecular Biology,
Hills Road,
Cambridge, CB2 0QH, UK.
http://www2.mrc-lmb.cam.ac.uk/group-leaders/h-to-m/g-jefferis
http://www.neuroscience.cam.ac.uk/directory/profile.php?gsxej2
http://flybrain.stanford.edu
Seemingly Similar Threads
- Read Windows BMP format images
- possible bug: graphics::image seems to ignore getOption("preferRaster")
- inflate zlib compressed data using base R or CRAN package?
- subscripting a data.frame (without changing row order) changes internal row.names
- 3d line smoothing
