R: how to find what S3 method will be called on an object?
问题 I know about methods() , which returns all methods for a given class. Suppose I have x and I want to know what method will be called when I call foo(x) . Is there a oneliner or package that will do this? The shortest I can think of is: sapply(class(x), function(y) try(getS3method('foo', y), silent = TRUE)) and then to check the class of the results... but is there not a builtin for this? Update The full one liner would be: fm <- function (x, method) { cls <- c(class(x), 'default') results <-