Re: [R] Substitute in function calling a function

2007-10-22 Thread Prof Brian Ripley
I am not sure what the general rule you are looking for is. Using deparse(substitute()) gets you the print-value of the expression (in your case a name) for the actual argument. But if you want to go back generations of calls, then just when do you stop? What you can do is write fun2 to use s

Re: [R] Substitute in function calling a function

2007-10-22 Thread Felix Andrews
I think the usual thing would be to pass substitute(x) or deparse(substitute(x)) from the original function (fun2 in your example). But if you really want to, you can do fun <- function(x) eval.parent(call("substitute", substitute(x))) On 10/22/07, Steve Powell <[EMAIL PROTECTED]> wrote: > Dear

[R] Substitute in function calling a function

2007-10-22 Thread Steve Powell
Dear list members, I am writing some functions to help with printing graphs. If I want to return the name of a variable within a function, for instance to print the label for a graph, I know that I can use substitute: fun=function(x) substitute(x) #plus of course some other processing var=1:3 fu