org.nuiton.j2r
Interface REngine

All Known Implementing Classes:
REngineAbstract, RJniEngine, RNetEngine, RProxy

public interface REngine

This interface is the common part between the different technologies used to access R.


Method Summary
 void clearSession()
          Remove all the objects present in the actual R session.
 void commit()
          Commit all the R instructions that have been stored and not commited yet.
 void cp(String source, String destination)
          Copy an object.
 void dget(String rObject, File inputFile)
          Use the dget rInstruction to store the content of a file (created with the dput instruction) into a R object.
 void dget(String rObject, String inputFileName)
          Use the dget rInstruction to store the content of a file (created with the dput instruction) into a R object.
 void dput(String rObject, File outputFile)
          Use the dput R instruction to store the content of a R object to a file.
 void dput(String rObject, String outputFileName)
          Use the dput R instruction to store the content of a R object to a file.
 Object eval(String expr)
          Evaluate the expression given in parameter in R.
 File getwd()
          Get the actual R session working directory
 boolean init()
          Initialize the engine.
 Boolean isAutoCommit()
          Return the autocommit status
 void loadRData(File directory)
          Load .RData file located in directory
 void loadRData(File directory, String fileName)
          Load a specific R session : Load the "fileName.RData" file located in directory.
 void loadRData(String filename)
          Load filename.RData file located in current working directory
 String[] ls()
          List all R object present in the actual session
 void mv(String source, String destination)
          Make a copy of an object and remove the old one.
 void remove(String rObject)
          Remove a R object from the actual session
 void saveRData(File directory)
          Save the session in a .RData file in directory
 void saveRData(File directory, String fileName)
          Save a R session in a fileName.RData file located in directory.
 void saveRData(String filename)
          Save a R session in a filename.RData file located in the current working directory
 void setAutoCommit(Boolean autocommit)
          Set the autocommit property.
 void setwd(File directory)
          Set the R working directory
 void terminate()
          End the engine use.
 void voidEval(String expr)
          Evaluate the expression given in parameter in R without result returned.
 

Method Detail

init

boolean init()
Initialize the engine. The parameters are given with the JVM options : -D...

Returns:
true/false to indicate if the initialization was succesful.

eval

Object eval(String expr)
            throws RException
Evaluate the expression given in parameter in R.

Parameters:
expr - the expression to evaluate.
Returns:
the value return by the expression.
Throws:
RException - if an error occur while trying to evaluate the expression.

voidEval

void voidEval(String expr)
              throws RException
Evaluate the expression given in parameter in R without result returned. When it is possible, it allows to save time (transfer and conversion from R to Java).

Parameters:
expr - the expression to evaluate
Throws:
RException - if an error occured while trying to evaluate the expression.

terminate

void terminate()
               throws RException
End the engine use.

Throws:
RException

loadRData

void loadRData(File directory)
               throws RException
Load .RData file located in directory

Parameters:
directory - directory where the .RData file is located
Throws:
RException

loadRData

void loadRData(String filename)
               throws RException
Load filename.RData file located in current working directory

Parameters:
filename - name of the .RData file (will be followed by .RData)
Throws:
RException

saveRData

void saveRData(File directory)
               throws RException
Save the session in a .RData file in directory

Parameters:
directory - where the .RData file will be saved
Throws:
RException

setwd

void setwd(File directory)
           throws RException
Set the R working directory

Parameters:
directory - to set
Throws:
RException

getwd

File getwd()
           throws RException
Get the actual R session working directory

Returns:
a File that is the actual R session working directory
Throws:
RException

dput

void dput(String rObject,
          String outputFileName)
          throws RException
Use the dput R instruction to store the content of a R object to a file. The file created will be in the working directory

Parameters:
rObject - name of the R object to save
outputFileName - name of the file to save
Throws:
RException

dget

void dget(String rObject,
          String inputFileName)
          throws RException
Use the dget rInstruction to store the content of a file (created with the dput instruction) into a R object. The file used have to be in the working directory

Parameters:
rObject - name of the R object created
inputFileName - name of the file to load
Throws:
RException

dput

void dput(String rObject,
          File outputFile)
          throws RException
Use the dput R instruction to store the content of a R object to a file.

Parameters:
rObject - R object to save
outputFile - the file to save
Throws:
RException

dget

void dget(String rObject,
          File inputFile)
          throws RException
Use the dget rInstruction to store the content of a file (created with the dput instruction) into a R object.

Parameters:
rObject - name of the R object created
inputFile - file to load
Throws:
RException

remove

void remove(String rObject)
            throws RException
Remove a R object from the actual session

Parameters:
rObject - to be removed from the session
Throws:
RException

mv

void mv(String source,
        String destination)
        throws RException
Make a copy of an object and remove the old one.

Parameters:
source - the object to be copied and deleted
destination - the object to be created
Throws:
RException

cp

void cp(String source,
        String destination)
        throws RException
Copy an object.

Parameters:
source - the object to be copied
destination - the object to be created
Throws:
RException

ls

String[] ls()
            throws RException
List all R object present in the actual session

Returns:
a list containing the name of all the R objects in the R session.
Throws:
RException

clearSession

void clearSession()
                  throws RException
Remove all the objects present in the actual R session.

Throws:
RException

setAutoCommit

void setAutoCommit(Boolean autocommit)
                   throws RException
Set the autocommit property. When switching from autocommit = false to true, the commit operation is performed.

Parameters:
autocommit - If true, R instructions are sent when they are thrown. If false, the instructions are stored in a LinkedList and the user needs to explicit the commit() instruction.
Throws:
RException - if an error occured during the commit operation.

isAutoCommit

Boolean isAutoCommit()
Return the autocommit status

Returns:
true if engine in auto-commit mode

commit

void commit()
            throws RException
Commit all the R instructions that have been stored and not commited yet.

Throws:
RException

loadRData

void loadRData(File directory,
               String fileName)
               throws RException
Load a specific R session : Load the "fileName.RData" file located in directory.

Parameters:
directory - directory where the ".RData" file is located
fileName - name of the file to load (will load the fileName.RData file)
Throws:
RException - if an error occur while loading the R session file.

saveRData

void saveRData(File directory,
               String fileName)
               throws RException
Save a R session in a fileName.RData file located in directory.

Parameters:
directory - where the ".RData" file will be located
fileName - name of the file to save (will save in the fileName.RData file)
Throws:
RException - if an error occur while saving the R session.

saveRData

void saveRData(String filename)
               throws RException
Save a R session in a filename.RData file located in the current working directory

Parameters:
filename -
Throws:
RException


Copyright © 2006-2010 CodeLutin. All Rights Reserved.