[R] evaluating expressions with sub expressions

Gabor Grothendieck ggrothendieck at gmail.com
Sat Jan 30 17:22:36 CET 2010


On Sat, Jan 30, 2010 at 10:39 AM, Jennifer Young
<Jennifer.Young at 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 home page
  http://ryacas.googlecode.com
first particularly the part about ensuring you have the right version
of XML installed).  Below, Sym creates a symbolic variable:

> library(Ryacas)
Loading required package: XML
> f1 <- Sym("f1")
> s1 <- Sym("s1")
> Tm <- Sym("Tm")
> g1 <- 1/Tm
> mat <- f1 * s1 * g1
> mat
[1] "Starting Yacas!"
expression(f1 * s1/Tm)



More information about the R-help mailing list