Re: [R] Obtaining argument name within a function

From: Sebastian Luque <spluque_at_gmail.com>
Date: Tue 19 Jul 2005 - 13:23:08 EST

"Francisco J. Zagmutt" <gerifalte28@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

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Tue Jul 19 13:30:02 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:46 EST