Skip to content
Prev 208084 / 398502 Next

evaluating expressions with sub expressions

Inline below...

-----Original Message-----
From: Gabor Grothendieck [mailto:ggrothendieck at gmail.com] 
Sent: Friday, January 29, 2010 2:12 PM
To: Bert Gunter
Cc: Jennifer Young; r-help at r-project.org
Subject: Re: [R] evaluating expressions with sub expressions

If its good enough to have one level of substitution then esub in my
post (originally due to Tony Plate -- see reference in my post) is all
that is needed:

esub(mat[[2]], list(g1 = g1[[1]]))

--- Yes, this is essentially what I did using lapply

but I think the real problem could require multiple levels of
substitution in which case repeated application of esub is needed as
you walk the expression tree which is what proc() in my post does.

-- Indeed. But my point was to handle the simple case simply.


To answer your question, quote() produces a call object but expression
produces a call wrapped in an expression which is why there is special
handling of expression objects in the proc() function in my post.

-- Aha! And of course I should have realized that I could have easily
determined this myself with:
[[1]]
`*`

[[2]]
a

[[3]]
b

## But ...
[[1]]
a * b
[1] "call"
[[1]]
`*`

[[2]]
a

[[3]]
b

So now all is clear to me.

Thanks to both Bill and Gabor for their informative replies.

-- Bert

Bert Gunter
Genentech Nonclinical Statistics
On Fri, Jan 29, 2010 at 4:38 PM, Bert Gunter <gunter.berton at gene.com> wrote:
also
I
return
I
On
expression.
http://www.R-project.org/posting-guide.html