[R] Substitute in function calling a function
Steve Powell
steve at promente.org
Mon Oct 22 10:13:09 CEST 2007
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
fun(var) #prints "var" as required, not "x".
But if I call this function in another function
fun2=function(y) fun(y) #plus of course some other processing
fun2(var) #prints "y" when what I wanted was "var"
I have tried lots of tricks using eval and expression but can't seem to get
it right. Any ideas?
Thanks in advance
Steve Powell
proMENTE social research
research | evaluation | training & consulting
Kranjčevićeva 35, 71000 Sarajevo
mobile: +387 61 215 997 | office: +387 33 556 865 | fax: +387 33 556 866
skype: stevepowell99
www.promente.org
Checked by AVG Free Edition.
19.10.2007
05:10
More information about the R-help
mailing list