de.uka.ipd.sdq.sensorframework.visualisation.rvisualisation.utils
Class RConnection

java.lang.Object
  extended by de.uka.ipd.sdq.sensorframework.visualisation.rvisualisation.utils.RConnection

public class RConnection
extends Object

Encapsulate the access to the R engine. Is responsible for the initialization of the R engine and the execution of R commands.

Author:
groenda

Constructor Summary
RConnection()
          Initializes the connection to the R engine.
 
Method Summary
 void assign(String name, double[] array)
          Stores an array in a R variable.
 Vector<REXP> execute(String rCommands)
          Executes the command(s) in R.
 String getLastConsoleMessage()
           
static RConnection getRConnection()
           
protected  void initalizeConnection()
          Initializes the connection to a R engine.
static boolean isEngineAvailable()
          checks if an R engine could be found and the connection is established.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RConnection

public RConnection()
Initializes the connection to the R engine.

Method Detail

initalizeConnection

protected void initalizeConnection()
Initializes the connection to a R engine.


execute

public Vector<REXP> execute(String rCommands)
Executes the command(s) in R.

Parameters:
rCommands - One or more valid commands in R, separated by \n.
Returns:
result Result returned from R. Empty if no result was returned.

assign

public void assign(String name,
                   double[] array)
Stores an array in a R variable.

Parameters:
name - Name of the R variable in which the array is stored.
array - Array to store in an R variable.

isEngineAvailable

public static boolean isEngineAvailable()
checks if an R engine could be found and the connection is established.

Returns:
true if the connection is established.

getRConnection

public static RConnection getRConnection()
Returns:
returns the current RConnection.

getLastConsoleMessage

public String getLastConsoleMessage()
Returns:
the last message on the console of the connected R engine.