5

我有一个参数列表,想通过 do.call 调用 B(var3=list(1:3))。但是下面的例子只调用了 dispatch “missing”的方法。如何访问调度“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)))
4

0 回答 0