[Rd] dispatching on group generics with more than one formal

Parlamis Franklin fparlamis at mac.com
Wed Oct 11 02:53:00 CEST 2006


please see the code below.  foo2 fails to dispatch correctly, but foo  
does fine.  i have tried 'cacheMetaData(1)' and a number of different  
variants of 'cacheGenericsMetaData', on the possibility there is a  
caching issue.  but i still can't sort it out.

also one general question: does it really matter what's in the body  
of the function definition in a 'setGroupGeneric' call?  the actual  
group function definition is always overwritten by a message to the  
effect the function should not be called directly.
__

setGroupGeneric("Foo", function(x) standardGeneric("Foo"))
setGroupGeneric("Foo2", function(x, y) standardGeneric("Foo2"))
setGeneric("foo", function(x) standardGeneric("foo"),
	group = "Foo", useAsDefault = function(x) "Default")
setGeneric("foo2", function(x, y) standardGeneric("foo2"),
	group = "Foo2", useAsDefault = function(x, y) "Default2")
setMethod("Foo", signature(x = "numeric"), function(x) "Special")
setMethod("Foo2", signature(x = "numeric", y = "missing"),
	function(x, y) "Special2")	
foo(1)  # gives the group method
foo2(1) # gives the default method
selectMethod("foo2", signature(x = "numeric", y = "missing")) # but  
method selection appears to work correctly

__

franklin parlamis

 > version

platform       powerpc-apple-darwin8.7.0
arch           powerpc
os             darwin8.7.0
system         powerpc, darwin8.7.0
status
major          2
minor          4.0
year           2006
month          10
day            03
svn rev        39566
language       R
version.string R version 2.4.0 (2006-10-03)




More information about the R-devel mailing list