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 of g1 vals <- data.frame(f1=1, s1=.5, Tm=2) # one set of possible values for variables before adding this sub expression I was using the following to evaluate "mat" sapply(mat, eval, vals) Obviously I could manually substitute in 1/Tm for each g1 in the definition of "mat", but the actual expression vector is much longer, and the sub expression more complicated. Also, the subexpression is often adjusted for different scenarios. Is there a simple way of changing this or redefining "mat" so that I can define "g1" like a macro to be used in the expression vector. Thanks! Jennifer ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.