If only named arguments to the S4 common function are defined in the method, substitute() works as expected:
> setGeneric("fS4", function(x, ...) standardGeneric("fS4")) > setMethod("fS4", signature("numeric"), + function(x, ...) deparse(substitute(x)) + ) [1] "fS4" > fS4(iris[,1]) [1] "iris[, 1]"
However, if you add an additional name argument to the method definition, substitute() stops returning the argument correctly as it is passed:
> setMethod("fS4", signature("numeric"), + function(x, y, ...) deparse(substitute(x)) + ) [1] "fS4" > fS4(iris[,1]) [1] "x"
Any clues on why this is happening, and most importantly, how to get around it?
source share