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
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
: Re: [Rd] as.name and namespaces
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
'as.name' doesn't recognize a name with
its namespace extension as a name:
as.name(lm)
lm
as.name(stats::lm)
`stats::lm`
as.name(stats:::lm)
`stats:::lm`
Is there a reason why it shouldn't?
Pat
--
Patrick Burns
pbu...@pburns.seanet.com
twitter: @burnsstat @portfolioprobe
On Apr 23, 2013, at 19:23 , Patrick Burns wrote:
'as.name' doesn't recognize a name with
its namespace extension as a name:
as.name(lm)
lm
as.name(stats::lm)
`stats::lm`
as.name(stats:::lm)
`stats:::lm`
Is there a reason why it shouldn't?
Any reason why it should? :: and :::
Okay, that's a good reason why it shouldn't.
Why it should is that I want to substitute
the first element of a call to be a function
including the namespace.
Pat
On 23/04/2013 18:32, peter dalgaard wrote:
On Apr 23, 2013, at 19:23 , Patrick Burns wrote:
'as.name' doesn't recognize a name
On Apr 23, 2013, at 21:51 , Patrick Burns wrote:
Okay, that's a good reason why it shouldn't.
Why it should is that I want to substitute
the first element of a call to be a function
including the namespace.
Offhand, I'd say that it shouldn't be a problem, but do you have a more
concrete
On 13-04-23 3:51 PM, Patrick Burns wrote:
Okay, that's a good reason why it shouldn't.
Why it should is that I want to substitute
the first element of a call to be a function
including the namespace.
Three ways:
1. Assign the function from the namespace locally, then call the local one.
2.