Hi guys,
Just wondering if there is an easy way to extract the argument names of a particular method? For example the following function foo
has methods for list or data.frame objects each with different arguments:
# Set generic for foo()
setGeneric(name = "foo", def = function(x, ...) {standardGeneric("foo")})
# list method for 'foo'
setMethod(foo, signature = "list", definition = function(x, y, z){
# Do something here
})
# data.frame method for 'foo'
setMethod(foo, signature = "data.frame", definition = function(x, y, z, a, b){
# Do something here
})
I would like to return name of the arguments for the data.frame method, i.e. expect arguments 'x', 'y', 'z', 'a' and 'b'.
I have tried calling args()
and argsAnywhere()
on foo
but it returns the definition for the generic - function(x,...)
. Is there an easy way to get a list of arguments for a particular method?
Thanks in advance for your help.
Dillon