[R] Obtaining argument name within a function
Sebastian Luque
spluque at gmail.com
Tue Jul 19 05:23:08 CEST 2005
"Francisco J. Zagmutt" <gerifalte28 at hotmail.com> wrote:
> Dear all
>
> How can I obtain the name of the argument passed in a function? Here is a
> simplistic example of what I would like to obtain:
>
> myfunction= function(name) {
> print(paste("The parameter name was",unknownFunction(name))
> }
>
> myfunction(myobject)
> [1] "The parameter name was myobject"
?substitute
myfunction <- function(obj) {
paste("The parameter name was", deparse(substitute(obj)))
}
myfunction(myobject)
--
Sebastian P. Luque
More information about the R-help
mailing list