Thanks to Berton Gunter and Peter Ehlers who both effectively solved
my problem. Prof. Gunter's solution, slightly more succinct, is:
foo <- function(x)
{
if(is.name(sb <- substitute(x))) deparse(sb)
else eval(sb)
}
(appropriately modified to fit into the ``mv()'' context.
Duncan Murdoch expressed the worry:
How could you tell what a user intended who typed this?
name1 <- "a"
name2 <- "b"
mv(name1, name2)
Well, I guess I couldn't. I am not actually bothered by this
however. I only want mv() to work with the arguments being
either names or expressions which evaluate to explicit text strings.
What ***I*** would intend by mv(name1,name2) in those circumstances
would be in effect:
name2 <- name1
rm(name1)
I.e. I want mv() to apply to the objects ``name1'' and ``name2''.
The fact that these objects consist of text strings which *could*
name other objects is of no importance (to me).
Thanks again to all who responded.
cheers,
Rolf Turner
######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.