Is there a way to get all the functional parameters inside a function?
match.call() does not return parameters with default values ββbut not overridden. For example:
xf <- function (a, b="Hi", c=TRUE) { print(as.list(match.call(expand.dots=FALSE))) } >xf(3) [[1]] xf $a [1] 3
I am writing a package with a function that calls an existing function, but I want to be able to set default values ββthat are not in the existing function. (I planned to use the list from match.call , passing it to another function using do.call and returning the result.
Update: An interesting issue related to S3 methods. I created a new S3 method and used the answer @ Ferdinand.kraft. as.list(environment(), all.names=TRUE) The all.names argument saves names starting with . in the list. It turns out that sending a method adds a few arguments to the function environment, including .Generic .Class .Method and several others. This can cause problems if you pass them to the do.call function. One of the other answers may be a better solution, but I like the simplicity of as.list(environment()) .
Seth
source share