[Rd] as.name and namespaces

peter dalgaard pdalgd at gmail.com
Wed Apr 24 11:47:35 CEST 2013


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



More information about the R-devel mailing list