5

I have a list of parameters and would like to call B(var3=list(1:3)) via do.call. But the following example only calls the method for dispatch "missing". How do I access the method for dispatch "ANY"?

B.initialize<-function(..., var3=list()){
  callSuper(..., var3=as.list(var3))
}

.B<-setRefClass(Class = "B"
               ,fields = list(var3 = "list")
               ,methods = list(initialize=B.initialize))
setGeneric("B", function(x, ...) standardGeneric("B"))
setMethod("B", "missing", function(x, ...) {
  .B()
})
setMethod("B", "ANY", function(x, ...) {
  .Part(var1=x, ...)
})
do.call(B,list(var3=list(1:3)))
John Paul
  • 12,196
  • 6
  • 55
  • 75
Klaus
  • 1,946
  • 3
  • 19
  • 34
  • You need to pass the argument for `x` to your method "B", e.g. 123 in the example: `do.call(B, list(123, var3=list(1:3)))` – Jerzy Jul 11 '16 at 17:01

0 Answers0