Skip to content
Prev 273519 / 398506 Next

do calculations as defined by a string / expand mathematical statements in R

Avoid parsing strings to make expressions.  It is easy
to do, but hard to do safely and readably.

In your case you could make a short loop out of it
   result <- x[,,,1]
   for(i in seq_len(dim(x)[4])[-1]) {
      result <- result + x[,,,i]
   }
   result <- result / dim(x)[4] 

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com