If any column is passed using RVar, a vector of the same size and name will be created within the R environment. If a vector is fetched from R and it matches the size of a column in the calling context, then a column will automatically be created.
Using Rvar doesn't change the scope or life of varables in either Seer or R.
Passing simple scalars to R:
Sets the R variable five to the value 5. If the variable doesn't exist it will be created automatically
Sets the R variable name to the string bob. If the variable doesn't exist it will be created automatically
Returning simple scalars from R:
The variable $ans will contain the value of the R variable five. If the R variable does not exist undef will be returned.
Complex data types - Arrays and Vectors
A common R data type is the vector. Vectors can be passed to R from Seer as an array reference. Vectors will be returned from R as array references.
Passing an array (vector) to R:
RVar('x',[1,2,3,4,5,6,7]);
RVar('z', \ @mydata);
In the last example, the forward slash is used to create an reference to the array mydata.
Examples passing data to R:
#Pass the OHLCV columns from Seer to R. The columns will become R vectors of the same name.
RVar(Open,High,Low,Close,Volume);
Examples returning data to Seer: