From pdalgd at gmail.com  Wed Apr 24 11:47:35 2013
From: pdalgd at gmail.com (peter dalgaard)
Date: Wed, 24 Apr 2013 11:47:35 +0200
Subject: [Rd] as.name and namespaces
In-Reply-To: <5177A607.10706@pburns.seanet.com>
References: <5176C393.9090802@pburns.seanet.com>
	<3F6D53EB-1C02-42B4-AD2D-085D9E9E94C3@gmail.com>
	<5176E65B.50500@pburns.seanet.com> <5176EC94.3060607@gmail.com>
	<5177A607.10706@pburns.seanet.com>
Message-ID: <B2C57DB2-44AE-440D-BF43-C44115B3E4D4@gmail.com>

There's also the brute force option:

> mycall <- expression(lm(Y ~ x))[[1]]
> mycall[[1]] <- quote(stats::lm)
> mycall
stats::lm(Y ~ x)
> eval(mycall, list(Y=rnorm(5),x=1:5))

Call:
stats::lm(formula = Y ~ x)

Coefficients:
(Intercept)            x  
    0.07430      0.02981  


On Apr 24, 2013, at 11:29 , Patrick Burns wrote:

> Here is an example problem:
> 
> > mycall <- expression(lm(Y ~ x))[[1]]
> > mycall
> lm(Y ~ x)
> > newname <- "stats::lm"
> 
> > desiredResult
> stats::lm(Y ~ x)
> 
> I've solved the problem in the kludgy way of
> deparsing, fixing the string and then parsing.
> 
> I like Duncan's third method, but it seems like
> it assumes the solution.  Moving functions around
> is unappetizing for my use -- this is for testing
> and keeping things as faithful to real use is a
> good thing.
> 
> Pat

-- 
Peter Dalgaard, Professor
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



[Rd] as.name and namespaces
peter dalgaard