[R] using the name of an argument in a function

2010-05-25 Thread cgenolin
Hi all, In a function, I need to get the name of a variable that has been used to call the function. For example, I want: --- 8 -- toto - 3 fun - function(y){ nameOfY -deparse(substitute(y)) cat(name is ,nameOfY) } fun(toto) # [1] name is toto --- 8 But deparse(substitute(y))

Re: [R] using the name of an argument in a function

2010-05-25 Thread Romain Francois
Hi, This is a dangerous game you are playing. I would play with the call stack, i.e sys.calls : setMethod(fun,character, definition = function(y,x,...){ stack - sys.calls( ) stack.fun - Filter( function(.) .[[1]] == as.name(fun), stack ) nameOfY -