Adding S4 dispatch to base R S3 generic

后端 未结 1 560
慢半拍i
慢半拍i 2020-12-09 13:33

I am trying to add a spatial method to merge which needs to be S4 (since it dispatches on the types of two different objects).

I have tried using an ear

相关标签:
1条回答
  • 2020-12-09 14:11

    The mis-dispatch occurs because the body of the generic is not "standard" (I think the rationale is that, since you've done something other than invoke standardGeneric("merge"), you know what you're doing so no automatic default; maybe I'm making this up and it's really a bug). Solutions are to set a standard generic allowing for the default dispatch

    setGeneric("merge")
    

    or to explicitly provide standard dispatch

    setGeneric("merge", function(x, y, ...) standardGeneric("merge"))
    

    or explicitly specify a default method

    setGeneric("merge", function(x, y, ...){
      cat("generic dispatch\n")
      standardGeneric("merge")
    }, useAsDefault=base::merge)
    
    0 讨论(0)
提交回复
热议问题