Hello R-List, ** This e-mail was initially bounced. Please forgive any duplicates.**
I'm creating a new generic function and 3 associated methods, in which each of the methods only needs a subset of the arguments specified in the generic. So, I create the generic like so (with the signature defaulting to all of the args) ... setGeneric( name="myFunction", def = function(filename, dimLengths, dimSteps, dimStarts, likeTemplate, likeFile) { standardGeneric("myFunction") } ) In my first method, for example, I only need access to the first 4 args, so I try ... setMethod( "myFunction", signature=signature(filename="character", dimLengths="numeric", dimSteps="numeric", dimStarts="numeric"), definition=function(filename=filename, dimLengths=NULL, dimSteps=NULL, dimStarts=NULL) { ... } Now, when I build the package, I get the following warning ... In method for function "myFunction": expanding the signature to include omitted arguments in definition: likeTemplate = "missing", likeFile = "missing" I've read in "S4 Classes in 15 pages, more or less" (John Chambers), that a method *can* contain a subset of the args in the generic, so I'm uncertain why R is "expanding the signature". I suspect that all methods need to include all signature elements specified within the generic, even if the signature elements are not in the method's arg list ... is this correct? At any rate, I do not want the signature to be expanded, since (1) I don't want to add these 2 "missing" args to my Rd \alias's, and (2) I don't want to have to add these 2 missing args to the \S4method Rd entry, as it makes these entries horribly long and does not really add any useful information for the user. Perhaps I'm not setting up these methods optimally? What I *want* is to be able to have 3 methods that could be invoked as follows: Method 1: myFunction(filename, dimLengths, dimSteps, dimStarts) Method 2: myFunction(filename, likeTemplate="templete") -> likeTemplate="character" Method 3: myFunction(filename, likeFile="file") -> likeFile="character" Note that the arguments for Methods 2 & 3 are both ("character", "character"). Does anyone have any suggestions that would both solve my S4 dispatch problem, whilst keeping the Rd doc user friendly (i.e., not polluting the entries with "missing" arguments)? Thanks in advance for any suggestions. Sincerely, -Jim > sessionInfo() R version 2.10.1 (2009-12-14) i386-apple-darwin9.8.0 locale: [1] en_CA.UTF-8/en_CA.UTF-8/C/C/en_CA.UTF-8/en_CA.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base -- ================================= Jim Nikelski, Ph.D. Postdoctoral Research Fellow Bloomfield Centre for Research in Aging Lady Davis Institute for Medical Research Sir Mortimer B. Davis - Jewish General Hospital McGill University ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.