Skip to content
Back to formatted view

Raw Message

Message-ID: <06E00787-98D0-45E4-B565-3EBB09169B76@auckland.ac.nz>
Date: 2010-01-19T00:51:16Z
From: Rolf Turner
Subject: An argument processing puzzle --- solution.
In-Reply-To: <4B54DFC2.1030204@stats.uwo.ca>

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}}