|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.jstacs.utils.REnvironment
public class REnvironment
This is an environment class for R and Rserve that helps you to handle all things in a more gentle way.
RUtils| Constructor Summary | |
|---|---|
REnvironment()
This constructor creates a connection to an R instance on the "localhost" with empty login and password. |
|
REnvironment(String server,
int port,
String user,
String passwd)
Creates a new REnvironment with initial size 10 using the given
port. |
|
REnvironment(String server,
int port,
String user,
String passwd,
int initSize)
Creates a new REnvironment using the given port. |
|
REnvironment(String server,
String user,
String passwd)
Creates a new REnvironment with initial size 10 using the default
port. |
|
REnvironment(String server,
String user,
String passwd,
int initSize)
Creates a new REnvironment using the default port. |
|
| Method Summary | |
|---|---|
void |
close()
Closes the REnvironment and removes all files from the server. |
boolean |
copyFileFromServer(String serverFileName,
String clientFileName,
boolean overwriteExistingFile)
Copies a file from the server to the local machine. |
boolean |
copyFileToServer(String clientFileName,
String serverFileName,
boolean overwriteExistingFile)
Copies a file from the local machine to the server. |
REXP |
createMatrix(String matrixName,
double[][] matrix)
Creates a matrix of doubles. |
REXP |
createMatrix(String matrixName,
int[][] matrix)
Creates a matrix of ints. |
REXP |
createVector(String vectorName,
double[] vector)
Creates a vector of doubles. |
REXP |
createVector(String vectorName,
int[] vector)
Creates a vector of ints. |
REXP |
createVector(String vectorName,
long[] vector)
Creates a vector of longs. |
REXP |
createVector(String vectorName,
String[] vector)
Creates a vector of Strings. |
void |
deleteAllFilesAtTheServer()
Deletes all files that have been copied to the server or created on the server. |
REXP |
eval(CharSequence cmd)
Evaluates the String as R commands. |
protected void |
finalize()
|
String |
getVersionInformation()
Returns information about the version of R that is used. |
void |
installScript(String clientFileName,
String serverFileName,
boolean overwriteExistingFile)
Installs a script on the server. |
BufferedImage |
plot(CharSequence pltcmd)
Creates a buffered image from a given plot command. |
BufferedImage |
plot(CharSequence pltcmd,
double width,
double height)
Creates a buffered image with given dimension from a given plot command. |
void |
plot(CharSequence pltcmd,
double width,
double height,
String formatName,
OutputStream out)
This method creates an image with given dimension from a given plot command and pipes it to the output stream. |
boolean |
plotToPDF(CharSequence pltcmd,
double width,
double height,
String fileName,
boolean overwriteExistingFile)
Creates a pdf file with given dimension from a given plot command. |
boolean |
plotToPDF(CharSequence pltcmd,
String fileName,
boolean overwriteExistingFile)
Creates a pdf file from a given plot command. |
boolean |
plotToTexFile(CharSequence pltcmd,
double width,
double height,
String fileName,
boolean overwriteExistingFile)
Creates a tex file with given dimension from a given plot command. |
boolean |
plotToTexFile(CharSequence pltcmd,
String fileName,
boolean overwriteExistingFile)
Creates a tex file from a given plot command. |
static JFrame |
showImage(String title,
BufferedImage img)
Enables you to show an image. |
static JFrame |
showImage(String title,
BufferedImage img,
int defaultCloseOperation)
Enables you to show an image. |
void |
voidEval(CharSequence cmd)
Evaluates the String as R commands. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public REnvironment()
throws Exception
Exception - if something went wrongREnvironment(String, String, String)
public REnvironment(String server,
String user,
String passwd,
int initSize)
throws Exception
REnvironment using the default port.
server - the name of the serveruser - the loginpasswd - the password for the logininitSize - the initial number of slots for files on the server (has to be
at least 1)
Exception - if something went wrong
public REnvironment(String server,
String user,
String passwd)
throws Exception
REnvironment with initial size 10 using the default
port.
server - the name of the serveruser - the loginpasswd - the password for the login
Exception - if something went wrongREnvironment(String, String, String, int)
public REnvironment(String server,
int port,
String user,
String passwd,
int initSize)
throws Exception
REnvironment using the given port.
server - the name of the serverport - the portuser - the loginpasswd - the password for the logininitSize - the initial number of slots for files on the server (has to be
at least 1)
Exception - if something went wrong
public REnvironment(String server,
int port,
String user,
String passwd)
throws Exception
REnvironment with initial size 10 using the given
port.
server - the name of the serverport - the portuser - the loginpasswd - the password for the login
Exception - if something went wrongREnvironment(String, String, String, int)| Method Detail |
|---|
public boolean copyFileFromServer(String serverFileName,
String clientFileName,
boolean overwriteExistingFile)
throws Exception
serverFileName - name of the file on the serverclientFileName - name of the file on the client (local machine)overwriteExistingFile - whether to overwrite the file, if already existing on the
client
true if the file is copied successfully
Exception - if something went wrong
public boolean copyFileToServer(String clientFileName,
String serverFileName,
boolean overwriteExistingFile)
throws Exception
serverFileName - name of the file on the serverclientFileName - name of the file on the client (local machine)overwriteExistingFile - whether to overwrite the file, if already existing on the
server
true if the file is copied successfully
Exception - if something went wrong
public void close()
throws Exception
REnvironment and removes all files from the server.
Exception - if something went wrong
public REXP createMatrix(String matrixName,
int[][] matrix)
throws RserveException,
IllegalArgumentException
ints.
matrixName - the name of the matrixmatrix - the matrix of ints
RserveException - if something with Rserve went wrong
IllegalArgumentException - if matrix[i].length != matrix[j].length
public REXP createMatrix(String matrixName,
double[][] matrix)
throws RserveException,
IllegalArgumentException
doubles.
matrixName - the name of the matrixmatrix - the matrix of doubles
RserveException - if something with Rserve went wrong
IllegalArgumentException - if matrix[i].length != matrix[j].length
public REXP createVector(String vectorName,
String[] vector)
throws RserveException
Strings.
vectorName - the name of the vectorvector - the vector of Strings
RserveException - if something with Rserve went wrong
public REXP createVector(String vectorName,
int[] vector)
throws RserveException
ints.
vectorName - the name of the vectorvector - the vector of ints
RserveException - if something with Rserve went wrong
public REXP createVector(String vectorName,
long[] vector)
throws RserveException
longs.
vectorName - the name of the vectorvector - the vector of longs
RserveException - if something with Rserve went wrong
public REXP createVector(String vectorName,
double[] vector)
throws RserveException
doubles.
vectorName - the name of the vectorvector - the vector of doubles
RserveException - if something with Rserve went wrong
public void deleteAllFilesAtTheServer()
throws Exception
Exception - if something went wrong
public REXP eval(CharSequence cmd)
throws Exception
String as R commands.
cmd - the String to be evaluated
Exception - if something went wrong
public String getVersionInformation()
throws Exception
Exception - if something went wrong
public void installScript(String clientFileName,
String serverFileName,
boolean overwriteExistingFile)
throws Exception
clientFileName - the name of the scriptfile on the clientserverFileName - the name of the scriptfile on the serveroverwriteExistingFile - if true the method is enabled to overwrite an
existing file
Exception - if something went wrong
public BufferedImage plot(CharSequence pltcmd)
throws Exception
pltcmd - the plot command
Exception - if something went wrongplot(CharSequence, double, double),
showImage(String, BufferedImage),
ImageIO.write(java.awt.image.RenderedImage, String, File)
public BufferedImage plot(CharSequence pltcmd,
double width,
double height)
throws Exception
pltcmd - the plot commandwidth - the width of the image (in pixel)height - the height of the image (in pixel)
Exception - if something went wrongshowImage(String, BufferedImage),
ImageIO.write(java.awt.image.RenderedImage, java.lang.String,
java.io.File)
public void plot(CharSequence pltcmd,
double width,
double height,
String formatName,
OutputStream out)
throws IOException,
Exception
pltcmd - the plotting commandwidth - the width of the imageheight - the height of the imageformatName - the name of the image format used for writing the image (see ImageIO)out - the OutputStream used for writing the image
IOException - see ImageIO.write(java.awt.image.RenderedImage, String, OutputStream)
Exception - see plot(CharSequence, double, double)ImageIO.write(java.awt.image.RenderedImage, String, OutputStream)
public boolean plotToPDF(CharSequence pltcmd,
String fileName,
boolean overwriteExistingFile)
throws Exception
pltcmd - the plot commandfileName - the name of the pdf fileoverwriteExistingFile - if true the method is enabled to overwrite an
existing file
true if the plot is done
Exception - if something went wrong
public boolean plotToPDF(CharSequence pltcmd,
double width,
double height,
String fileName,
boolean overwriteExistingFile)
throws Exception
pltcmd - the plot commandwidth - the width of the imageheight - the height of the imagefileName - the name of the pdf fileoverwriteExistingFile - if true the method is enabled to overwrite an
existing file
true if the plot is done
Exception - if something went wrong
public boolean plotToTexFile(CharSequence pltcmd,
String fileName,
boolean overwriteExistingFile)
throws Exception
pltcmd - the plot commandfileName - the name of the tex fileoverwriteExistingFile - if true the method is enabled to overwrite an
existing file
true if the plot is done
Exception - if something went wrong
public boolean plotToTexFile(CharSequence pltcmd,
double width,
double height,
String fileName,
boolean overwriteExistingFile)
throws Exception
pltcmd - the plot commandwidth - the width of the imageheight - the height of the imagefileName - the name of the tex fileoverwriteExistingFile - if true the method is enabled to overwrite an
existing file
true if the plot is done
Exception - if something went wrong
public void voidEval(CharSequence cmd)
throws Exception
String as R commands.
cmd - the String to be evaluated
Exception - if something went wrong
protected void finalize()
throws Throwable
finalize in class ObjectThrowable
public static JFrame showImage(String title,
BufferedImage img)
throws InterruptedException
title - the title of the frameimg - the image
InterruptedException - if the process is interruptedshowImage(String, BufferedImage, int)
public static JFrame showImage(String title,
BufferedImage img,
int defaultCloseOperation)
throws InterruptedException
title - the title of the frameimg - the imagedefaultCloseOperation - the variable used to control the window-closing operation
InterruptedException - if the process is interruptedWindowConstants
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||