Re: [R] evaluating expressions with sub expressions

2010-01-30 Thread Jennifer Young
Cc: r-help@r-project.org Subject: Re: [R] evaluating expressions with sub expressions The following recursively walks the expression tree.  The esub function is from this page (you may wish to read that entire thread): http://tolstoy.newcastle.edu.au/R/help/04/03/1245.html esub - function

Re: [R] evaluating expressions with sub expressions

2010-01-30 Thread Gabor Grothendieck
On Sat, Jan 30, 2010 at 10:39 AM, Jennifer Young jennifer.yo...@math.mcmaster.ca wrote: handling of variables in R to be very straightforward; sometimes I pine for Maple to do my algebra for me... There are several interfaces to Computer Algebra Systems in R. Try this (but read instructions on

[R] evaluating expressions with sub expressions

2010-01-29 Thread Jennifer Young
Hallo I'm having trouble figuring out how to evaluate an expression when one of the variables in the expression is defined separately as a sub expression. Here's a simplified example mat - expression(0, f1*s1*g1) # vector of formulae g1 - expression(1/Tm) # expansion of the definition

Re: [R] evaluating expressions with sub expressions

2010-01-29 Thread baptiste auguie
Hi, Would this do as an alternative syntax? g1 - quote(1/Tm) mat - list(0, bquote(f1*s1*.(g1))) vals - data.frame(f1=1, s1=.5, Tm=2) sapply(mat, eval, vals) HTH, baptiste On 29 January 2010 17:51, Jennifer Young jennifer.yo...@math.mcmaster.ca wrote: Hallo I'm having trouble figuring out

Re: [R] evaluating expressions with sub expressions

2010-01-29 Thread Jennifer Young
Hmm I *think* this will work, but may break in a further sub routine. It certainly works in this example, but my expression vector is used in many scenarios and it will take a while to check them all. For instance, I take the derivative of each element with respect to each variable using

Re: [R] evaluating expressions with sub expressions

2010-01-29 Thread Gabor Grothendieck
The following recursively walks the expression tree. The esub function is from this page (you may wish to read that entire thread): http://tolstoy.newcastle.edu.au/R/help/04/03/1245.html esub - function(expr, sublist) do.call(substitute, list(expr, sublist)) proc - function(e, env =

Re: [R] evaluating expressions with sub expressions

2010-01-29 Thread Bert Gunter
[mailto:r-help-boun...@r-project.org] On Behalf Of Gabor Grothendieck Sent: Friday, January 29, 2010 11:01 AM To: Jennifer Young Cc: r-help@r-project.org Subject: Re: [R] evaluating expressions with sub expressions The following recursively walks the expression tree. The esub function is from this page

Re: [R] evaluating expressions with sub expressions

2010-01-29 Thread William Dunlap
- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Bert Gunter Sent: Friday, January 29, 2010 1:38 PM To: 'Gabor Grothendieck'; 'Jennifer Young' Cc: r-help@r-project.org Subject: Re: [R] evaluating expressions with sub expressions Folks: Stripped

Re: [R] evaluating expressions with sub expressions

2010-01-29 Thread Gabor Grothendieck
: r-help@r-project.org Subject: Re: [R] evaluating expressions with sub expressions The following recursively walks the expression tree.  The esub function is from this page (you may wish to read that entire thread): http://tolstoy.newcastle.edu.au/R/help/04/03/1245.html esub - function(expr

Re: [R] evaluating expressions with sub expressions

2010-01-29 Thread Bert Gunter
Inline below... -Original Message- From: Gabor Grothendieck [mailto:ggrothendi...@gmail.com] Sent: Friday, January 29, 2010 2:12 PM To: Bert Gunter Cc: Jennifer Young; r-help@r-project.org Subject: Re: [R] evaluating expressions with sub expressions If its good enough to have one level