Displaying 20 results from an estimated 81 matches for "evalq".
Did you mean:
eval
2020 Jun 01
1
eval and Calling Frames
I ran into an interesting issue with `evalq` (and also
`eval(quote(...))`):
???? f <- function() {
?????? list(
???????? sys.parent(1),
???????? evalq(sys.parent(1)),
???????? evalq((function() sys.parent(2))()),? # add an anon fun layer
???????? evalq((function() sys.parent(1))())
?????? )
???? }
???? res <- f()
???? str(res)
???? ##...
2015 Jul 15
3
bquote/evalq behavior changed in R-3.2.1
In 3.1.2 eval does not store the result of the bquote-generated call in the
given environment. Interestingly, in 3.2.1 eval does store the result of
the bquote-generated call in the given environment.
In other words if I run the given example with eval rather than evalq, on
3.1.2 "x" is never stored in "fenv," but it is when I run the same code on
3.2.1. However, the given example stores "x" in "fenv" on 3.1.2, but throws
the error I gave when run on 3.2.1.
To give credit, I received the idea for using evalq from SO:
http:/...
2007 May 27
2
Question about "evalq"
The help page of eval says: The 'evalq' form is equivalent to
'eval(quote(expr), ...)'. But the following is not equivalent. Can
anyone give me some explaination? Thanks very much.
> f1 <- function(x,digits=5) lapply(x, f2)
> f2 <- function(x) eval(quote(print(x+1,digits=digits)),list(x=x),parent.frame(2))
>...
2015 Jul 15
2
bquote/evalq behavior changed in R-3.2.1
...g eval with an expression-object rather than a call-object seemed to solve the problem when this was posed as a question on StackOverflow, but Dayne was not happy with that solution for other reasons that he is not describing.
--
David.
> In R-3.1.3 we got
> rapply(list(quote(1+myNumber)), evalq, envir=list2env(list(myNumber=17)))
> #[1] 18
> rapply(list(quote(1+myNumber)), eval, envir=list2env(list(myNumber=17)))
> #Error in (function (expr, envir = parent.frame(), enclos = if
> (is.list(envir) || :
> object 'myNumber' not found
> lapply(list(quote(1+myNumber))...
2015 Jul 15
0
bquote/evalq behavior changed in R-3.2.1
I think rapply() was changed to act like lapply() in this respect.
In R-3.1.3 we got
rapply(list(quote(1+myNumber)), evalq, envir=list2env(list(myNumber=17)))
#[1] 18
rapply(list(quote(1+myNumber)), eval, envir=list2env(list(myNumber=17)))
#Error in (function (expr, envir = parent.frame(), enclos = if
(is.list(envir) || :
object 'myNumber' not found
lapply(list(quote(1+myNumber)), evalq, envir=list2env(list(...
2015 Jul 15
3
bquote/evalq behavior changed in R-3.2.1
...reviously. Briefly, I am using bquote to generate
expressions to modify data.table objects within a function, so I need the
changes to actually be stored in the given environment. Previously, I used
code like the following:
test <- list(bquote(x <- 10))
fenv <- environment()
rapply(test, evalq, envir = fenv)
Although the code in the example above is much simpler, it shows the
problem. On 3.1.2 the expression is evaluated and x is stored as 10 in the
given environment, fenv. In 3.2.1 the code throws an error:
Error in eval(substitute(expr), envir, enclos) : object 'X' not found...
2015 Jul 15
2
bquote/evalq behavior changed in R-3.2.1
...solve the
>> problem when this was posed as a question on StackOverflow, but Dayne was
>> not happy with that solution for other reasons that he is not describing.
>>
>> --
>> David.
>>
>> > In R-3.1.3 we got
>> > rapply(list(quote(1+myNumber)), evalq,
>> envir=list2env(list(myNumber=17)))
>> > #[1] 18
>> > rapply(list(quote(1+myNumber)), eval, envir=list2env(list(myNumber=17)))
>> > #Error in (function (expr, envir = parent.frame(), enclos = if
>> > (is.list(envir) || :
>> > object 'myNum...
2015 Jul 15
0
bquote/evalq behavior changed in R-3.2.1
...er than a call-object seemed to solve the problem
> when this was posed as a question on StackOverflow, but Dayne was not happy
> with that solution for other reasons that he is not describing.
>
> --
> David.
>
> > In R-3.1.3 we got
> > rapply(list(quote(1+myNumber)), evalq, envir=list2env(list(myNumber=17)))
> > #[1] 18
> > rapply(list(quote(1+myNumber)), eval, envir=list2env(list(myNumber=17)))
> > #Error in (function (expr, envir = parent.frame(), enclos = if
> > (is.list(envir) || :
> > object 'myNumber' not found
> >...
2015 Jul 15
0
bquote/evalq behavior changed in R-3.2.1
...hen this was posed as a question on StackOverflow, but Dayne was
>>> not happy with that solution for other reasons that he is not describing.
>>>
>>> --
>>> David.
>>>
>>> > In R-3.1.3 we got
>>> > rapply(list(quote(1+myNumber)), evalq,
>>> envir=list2env(list(myNumber=17)))
>>> > #[1] 18
>>> > rapply(list(quote(1+myNumber)), eval,
>>> envir=list2env(list(myNumber=17)))
>>> > #Error in (function (expr, envir = parent.frame(), enclos = if
>>> > (is.list(envir) || :...
2001 Oct 16
4
Assignment of structures on a given environment
...uot;l$a",20,env=ref)
it creates me a new variable in the ref environment named "l$a"
So, I did:
eval(l <- alist(), env=ref)
but this creates the l list both on the current and on the ref
environment.
The alternative solution that I found out was:
evalq(l<-alist(),env=ref)
and then
evalq(ind <-c("a","b"), env=ref)
evalq(l[ind] <- as.list(c(20,40)), env=ref)
I would like to know if there is another possible solution, instead of
doing these 'evalqs' along the program code.
Thanks,
R...
2007 May 18
1
subset arg in (modified) evalq
Hi,
When using evalq to evaluate expressions within a say data.frame context I often wish there was a 'subset' argument, much like in lm() or any ather advanced regression model. I would be grateful for a tip how to do this.
Here is an illustration of what I want:
n <- 100
data <- data.frame(x=rnorm(...
2015 Jul 15
0
bquote/evalq behavior changed in R-3.2.1
I am curious why you used evalq instead of eval in this code.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Wed, Jul 15, 2015 at 11:49 AM, Dayne Filer <dayne.filer at gmail.com> wrote:
> Hello,
>
> I upgraded from 3.1.2 to 3.2.1 and am receiving errors on code that worked
> as I intended previously. Briefly...
2002 Sep 04
3
strange things with eval and parent frames
...#39;s going on here?
First example:
> test.parent.funcs_ function() {
outer.var_ 5
subfunc1_ function() substitute( outer.var, envir=parent.frame())
print( subfunc1())
subfunc2b_ function() eval( quote( outer.var), envir=parent.frame())
print( subfunc2b())
subfunc2_ function() evalq( outer.var, envir=parent.frame())
#print( subfunc2())
}
> test.parent.funcs()
[1] 5
[1] 5
If you try this without the hash before the 3rd print statement, it crashes,
complaining it can't find outer.var. But AFAICS, subfunc2 and subfunc2b
should return the same thing. So, at a minimum,...
2009 Jan 28
1
evaluation revisited
...L[[len]],parent.frame()) # =0 MAKES SENSE
eval.parent(print(x)) # =1 WHY NOT ZERO ? Somehow this is
different from eval.parent(L[[len]])
eval(print(x)) # =1 MAKES SENSE
eval(print(x),parent.frame()) # =1 # WHY NOT ZERO ? Somehow this is
different from eval(L[[len]],parent.frame)
evalq(print(x)) # =1 MAKES SENSE
evalq(print(x),parent.frame()) # =1 MAKES SENSE
print("====================")
x <- 2
eval.parent(L[[len]]) # =0 MAKES SENSE
eval(L[[len]]) # =2 MAKES SENSE
eval(L[[len]],parent.frame()) # =0 MAKES SENSE
eval.parent(print(x)) # =2 WH...
2015 Apr 01
4
evaluation in transform versus within
On 01/04/2015 1:35 PM, Gabriel Becker wrote:
> Joris,
>
>
> The second argument to evalq is envir, so that line says, roughly, "call
> environment() to generate me a new environment within the environment
> defined by data".
I think that's not quite right. environment() returns the current
environment, it doesn't create a new one. It is evalq() that created...
2007 Jun 08
1
evaluating variables in the context of a data frame
Given
> D = data.frame(o=gl(2,1,4))
this works as I expected:
> evalq(o, D)
[1] 1 2 1 2
Levels: 1 2
but neither of these does:
> f <- function(x, dat) evalq(x, dat)
> f(o, D)
Error in eval(expr, envir, enclos) : object "o" not found
> g <- function(x, dat) eval(x, dat)
> g(o, D)
Error in eval(x, dat) : object "o" not found
Wha...
2015 Apr 01
2
evaluation in transform versus within
...never seen that warning on the help page of with() and within(), so I
assumed both functions can safely be used in functions and packages. I've
now been told that both functions pose the same risk as subset() and
transform().
Looking at the source code I've noticed the extra step:
e <- evalq(environment(), data, parent)
which, at least according to my understanding, should ensure that the
functions follow the standard evaluation rules. Could somebody with more
knowledge than I have shed a bit of light on this issue?
Thank you
Joris
--
Joris Meys
Statistical consultant
Ghent Univer...
2001 Oct 17
0
Assignment of structures on a given environment]
...$first$b
[1] 40
$second
[1] 50
and
> l$first$b
[1] 40
I'm searching for some alternative to solution to define
this hierarchy
in the designed environment, without needing to use the 'evalq'
command..... Is
there one?
Thanks again,
Rita
>
> One might ask whether you are sure that you need to do this?
> I work on very large data sets and copying has pretty much never
> been an issue.
>
> >
> >
> > So, I did:...
2015 Apr 01
1
evaluation in transform versus within
...d regards
> Joris
>
> On Wed, Apr 1, 2015 at 7:55 PM, Duncan Murdoch
> <murdoch.duncan at gmail.com <mailto:murdoch.duncan at gmail.com>> wrote:
>
> On 01/04/2015 1:35 PM, Gabriel Becker wrote:
>
> Joris,
>
>
> The second argument to evalq is envir, so that line says,
> roughly, "call
> environment() to generate me a new environment within the
> environment
> defined by data".
>
>
> I think that's not quite right. environment() returns the current
> enviro...
2015 Jan 26
2
Inspect a "delayed" assigned whose value throws an error?
...doesn't seem to help for reaching into the
namespace of hgu133a.db and inspecting 'hgu133aPFAM', e.g.
> library("hgu133a.db")
> substitute(hgu133aPFAM, env=ns)
Error: hgu133aPFAM is defunct. Please use select() if you need access to PFAM
or PROSITE accessions.
> evalq(substitute(hgu133aPFAM), envir=ns)
Error: hgu133aPFAM is defunct. Please use select() if you need access to PFAM
or PROSITE accessions.
> evalq(substitute(hgu133aPFAM, env=ns), envir=ns)
Error: hgu133aPFAM is defunct. Please use select() if you need access to PFAM
or PROSITE accessions.
Th...