Evaluate R expression and execute R code

The methods Eval(<expression>) and Execute(<code>) are similar to VBScript commands with same names.

First one evaluates an expression and returns the result value (scalar or matrix).

Second method executes piece of code and returns nothing.

NB If you are using R string constants in Eval or Exec, you must surround them with DOUBLE double quotation marks. e.g. to pass in R  x <- "the"  you have to write in Program field Rp1.Exec("x <- ""the"" ")


Example 1

Objective: Set R variable "a" to 4, and evaluate expression "2+3*a" in result field and in evaluation box on Rp tool. All the calculation here are executed in R.


Example 2

Objective: Set R variable "x" to 4; "y" - to 3; z - to 2*x+y+1 and get the last variable in result field.


Example 3

Objective: Execute R code from Memo1 and then get the "z" variable in result field.


Back to Top