From jefferis at mrc-lmb.cam.ac.uk  Fri Jul  6 12:57:44 2012
From: jefferis at mrc-lmb.cam.ac.uk (Dr Gregory Jefferis)
Date: Fri, 6 Jul 2012 11:57:44 +0100
Subject: [Rd] depends/suggests when making a new generic to override a
	function in a user package
Message-ID: <B4563F5A-E59B-402E-AEAF-18C2BC3728AA@mrc-lmb.cam.ac.uk>

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



[Rd] depends/suggests when making a new generic to override a function in a user package
Dr Gregory Jefferis