This document aims at presenting the Opus-R link module. It will allow calling R features directly from Opus.

The module was developed in Python, so as to allow use of the Opus TUI. It acts as a wrapper allowing interaction with an R-Python interface called Rpy2.

The module converts variables from Opus types to Python types and vice-versa. The variables are then used by Rpy2 to interact with R. This Opus-R link is called rpyWrap.

In essence, this allows the Opus user to call R functions with Opus-type arguments, and receive outputs in Opus-types too.

The conversion of variables is made by the conv() function. This function will call the overload method of the variable type sent in argument. The conv() function works both ways.

As not all variable types have equivalents in the other language, an exhaustive list of the possible conversions has been created (as of February, 2011).

There are more complex types to translate, such as vector, matrix, formula and the board of data.

Note that a Vector’s type depends on its contents (which are homogenous). Consequently, there are several vector types: vectors of floats, integers, characters, booleans as well as vectors of vectors.

Type equivalence:


For more details read this document. toto

Type conversion does not modify the data, so R functions can be called directly with Opus-type arguments and return Opus-type variables without loss of information.

From a practical point of view, using the wrapper is simple, as a single function makes the conversion both ways. However, in order to call R functions, the user has to know the correct Rpy syntax to call functions.

Actually we try to convert R-function in Opus-function and vice-versa.

 

Last Updated (Monday, 28 February 2011 03:43)