"Steven Lacey" <[EMAIL PROTECTED]> writes:
> I want to set a default value in a method of a generic function. This seems
> as though it should be possible. From R help on setMethod...
> So, I try this...
>
> setGeneric("test",function(x,y){standardGeneric("test")})
> setMethod("test","numeric",
> function(x,y=FALSE){
> browser()
> }
> )
>
I think you have to actually specify a default value in the definition
of the generic (I don't claim this makes any sense). That value won't
get used as long as you specify a default in the method.
setGeneric("foo", function(x, y=1) standardGeneric("foo"))
setMethod("foo", signature(x="character"),
function(x, y="world") cat(x, y, "\n"))
foo("hello")
setMethod("foo", signature(x="character"),
function(x, y) cat(x, y, "\n"))
foo("hello")
+ seth
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html