RGetVarSerialized()

Retrieves the deserialized value of a variable.

Synopsis

blob RGetVarSerialized( const string var, int userData= 0);

Parameters

Parameter Description
var R variable to deserialize value from.
userData User data of the function call. The user data variable can be set to an integer value and be used to detect errors when calling R functions. Set the variable to an integer value and when the function is called and an error occurs, the specified integer value is returned.

Return Value

Deserialized value of a variable

Description

Retrieves the deserialized value of a variable.

Example

The example calls the function REvalExpVar to evaluate an R expression and then returns the deserialized value of a variable.

#uses "CtrlR"
main()
{
  dyn_float df1 = makeDynFloat(31,31,33,32,34,33,32,35,29,34,38,40,37,38,36,36,36,39,38,40,35,32,34,32,34,29,29,28,31,28,30,34,33,28,31,32,33,33,33,35,36,36,40,38,40,37,40,38,40,38);
  dyn_float df2 = makeDynFloat(401,381,382,392,406,372,361,405,392,399,350,342,346,354,304,345,320,317,356,323,386,406,405,396,400,401,365,400,391,398,362,368,363,373,389,370,406,386,402,367,379,380,406,389,374,379,399,406,377,407);
  string err_desc;
  int context;
  string H_LINE = "***************************************************************************";
  dyn_dyn_float ddf1;
  dynAppend(ddf1,df1);
  dynAppend(ddf1,df2);
  //Function call REvalExpVar()->Evaluates an R expression and sets the result value for the R variable
  int rv = REvalExpVar(0, "cResult", "cor(%var%,%var%)", ddf1[1], ddf1[2]);
  if (RGetLastErr(err_desc, context, true) != 0)
  {
    DebugTN("Error occurred: " + err_desc);
  }
  else
  { 
    DebugN("REvalExpVar_test finished!");
    blob at = RGetVarSerialized("cResult"); //Retrieves the deserialized value of a variable.
    DebugN("Value of the variable cResult:", at);
    DebugN(H_LINE);
  }
}

Assignment

R Functions

Availability

R Control Extension