Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## de.jstacs.utils
Class REnvironment

    java.lang.Object
      de.jstacs.utils.REnvironment

    public class REnvironment

extends Object

This is an environment class for R that helps you to handle all things in a more gentle way.

Author:
  Jens Keilwagen

Constructor Summary
`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 `double`s.
`REXP` | `createMatrix(String matrixName, int[][] matrix)` Creates a matrix of `int`s.
`REXP` | `createVector(String vectorName, double[] vector)` Creates a vector of `double`s.
`REXP` | `createVector(String vectorName, int[] vector)` Creates a vector of `int`s.
`REXP` | `createVector(String vectorName, long[] vector)` Creates a vector of `long`s.
`REXP` | `createVector(String vectorName, String[] vector)` Creates a vector of `String`s.
`void` | `deleteAllFilesAtTheServer()` Deletes all files that have been copied to the server or created on the server.
`REXP` | `eval(String 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(String pltcmd)` Creates a buffered image from a given plot command.
`BufferedImage` | `plot(String pltcmd, double width, double height)` Creates a buffered image with given dimension from a given plot command.
`boolean` | `plotToPDF(String pltcmd, double width, double height, String fileName, boolean overwriteExistingFile)` Creates a pdf file with given dimension from a given plot command.
`boolean` | `plotToPDF(String pltcmd, String fileName, boolean overwriteExistingFile)` Creates a pdf file from a given plot command.
`boolean` | `plotToTexFile(String pltcmd, double width, double height, String fileName, boolean overwriteExistingFile)` Creates a tex file with given dimension from a given plot command.
`boolean` | `plotToTexFile(String 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(String 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

### REnvironment

    public REnvironment(String server,
                        String user,
                        String passwd,
                        int initSize)
                 throws Exception

  Creates a new `REnvironment` using the default port.

  Parameters:
    `server` - the name of the server
    `user` - the login
    `passwd` - the password for the login
    `initSize` - the initial number of slots for files on the server (has to be at least 1)
  Throws:
    `Exception` - if something went wrong

### REnvironment

    public REnvironment(String server,
                        String user,
                        String passwd)
                 throws Exception

  Creates a new `REnvironment` with initial size 10 using the default port.

  Parameters:
    `server` - the name of the server
    `user` - the login
    `passwd` - the password for the login
  Throws:
    `Exception` - if something went wrong
  See Also:
    `REnvironment(String, String, String, int)`

### REnvironment

    public REnvironment(String server,
                        int port,
                        String user,
                        String passwd,
                        int initSize)
                 throws Exception

  Creates a new `REnvironment` using the given port.

  Parameters:
    `server` - the name of the server
    `port` - the port
    `user` - the login
    `passwd` - the password for the login
    `initSize` - the initial number of slots for files on the server (has to be at least 1)
  Throws:
    `Exception` - if something went wrong

### REnvironment

    public REnvironment(String server,
                        int port,
                        String user,
                        String passwd)
                 throws Exception

  Creates a new `REnvironment` with initial size 10 using the given port.

  Parameters:
    `server` - the name of the server
    `port` - the port
    `user` - the login
    `passwd` - the password for the login
  Throws:
    `Exception` - if something went wrong
  See Also:
    `REnvironment(String, String, String, int)`

Method Detail

### copyFileFromServer

    public boolean copyFileFromServer(String serverFileName,
                                      String clientFileName,
                                      boolean overwriteExistingFile)
                               throws Exception

  Copies a file from the server to the local machine.

  Parameters:
    `serverFileName` - name of the file on the server
    `clientFileName` - name of the file on the client (local machine)
    `overwriteExistingFile` - whether to overwrite the file, if already existing on the client
  Returns:
    `true` if the file is copied successfully
  Throws:
    `Exception` - if something went wrong

### copyFileToServer

    public boolean copyFileToServer(String clientFileName,
                                    String serverFileName,
                                    boolean overwriteExistingFile)
                             throws Exception

  Copies a file from the local machine to the server.

  Parameters:
    `serverFileName` - name of the file on the server
    `clientFileName` - name of the file on the client (local machine)
    `overwriteExistingFile` - whether to overwrite the file, if already existing on the server
  Returns:
    `true` if the file is copied successfully
  Throws:
    `Exception` - if something went wrong

### close

    public void close()
               throws Exception

  Closes the `REnvironment` and removes all files from the server.

  Throws:
    `Exception` - if something went wrong

### createMatrix

    public REXP createMatrix(String matrixName,
                             int[][] matrix)
                      throws RserveException,
                             IllegalArgumentException

  Creates a matrix of `int`s.

  Parameters:
    `matrixName` - the name of the matrix
    `matrix` - the matrix of `int`s
  Returns:
    an R expression
  Throws:
    `RserveException` - if something with Rserve went wrong
    `IllegalArgumentException` - if `matrix[i].length != matrix[j].length`

### createMatrix

    public REXP createMatrix(String matrixName,
                             double[][] matrix)
                      throws RserveException,
                             IllegalArgumentException

  Creates a matrix of `double`s.

  Parameters:
    `matrixName` - the name of the matrix
    `matrix` - the matrix of `double`s
  Returns:
    an R expression
  Throws:
    `RserveException` - if something with Rserve went wrong
    `IllegalArgumentException` - if `matrix[i].length != matrix[j].length`

### createVector

    public REXP createVector(String vectorName,
                             String[] vector)
                      throws RserveException

  Creates a vector of `String`s.

  Parameters:
    `vectorName` - the name of the vector
    `vector` - the vector of `String`s
  Returns:
    an R expression
  Throws:
    `RserveException` - if something with Rserve went wrong

### createVector

    public REXP createVector(String vectorName,
                             int[] vector)
                      throws RserveException

  Creates a vector of `int`s.

  Parameters:
    `vectorName` - the name of the vector
    `vector` - the vector of `int`s
  Returns:
    an R expression
  Throws:
    `RserveException` - if something with Rserve went wrong

### createVector

    public REXP createVector(String vectorName,
                             long[] vector)
                      throws RserveException

  Creates a vector of `long`s.

  Parameters:
    `vectorName` - the name of the vector
    `vector` - the vector of `long`s
  Returns:
    an R expression
  Throws:
    `RserveException` - if something with Rserve went wrong

### createVector

    public REXP createVector(String vectorName,
                             double[] vector)
                      throws RserveException

  Creates a vector of `double`s.

  Parameters:
    `vectorName` - the name of the vector
    `vector` - the vector of `double`s
  Returns:
    an R expression
  Throws:
    `RserveException` - if something with Rserve went wrong

### deleteAllFilesAtTheServer

    public void deleteAllFilesAtTheServer()
                                   throws Exception

  Deletes all files that have been copied to the server or created on the server.

  Throws:
    `Exception` - if something went wrong

### eval

    public REXP eval(String cmd)
              throws Exception

  Evaluates the `String` as R commands.

  Parameters:
    `cmd` - the `String` to be evaluated
  Returns:
    the result from R
  Throws:
    `Exception` - if something went wrong

### getVersionInformation

    public String getVersionInformation()
                                 throws Exception

  Returns information about the version of R that is used.

  Returns:
    information about the version of R that is used
  Throws:
    `Exception` - if something went wrong

### installScript

    public void installScript(String clientFileName,
                              String serverFileName,
                              boolean overwriteExistingFile)
                       throws Exception

  Installs a script on the server.

  Parameters:
    `clientFileName` - the name of the scriptfile on the client
    `serverFileName` - the name of the scriptfile on the server
    `overwriteExistingFile` - if `true` the method is enabled to overwrite an existing file
  Throws:
    `Exception` - if something went wrong

### plot

    public BufferedImage plot(String pltcmd)
                       throws Exception

  Creates a buffered image from a given plot command.
  If you use a java version below 1.6 your image is internally encoded as jpeg.
  If you use a java version at least 1.6 your image is internally encoded as png.

  Parameters:
    `pltcmd` - the plot command
  Returns:
    the buffered image
  Throws:
    `Exception` - if something went wrong
  See Also:
    `plot(String, double, double)`, `showImage(String, BufferedImage)`, `ImageIO.write(java.awt.image.RenderedImage, String, File)`

### plot

    public BufferedImage plot(String pltcmd,
                              double width,
                              double height)
                       throws Exception

  Creates a buffered image with given dimension from a given plot command.
  If you use a java version below 1.6 your image is internally encoded as jpeg.
  If you use a java version at least 1.6 your image is internally encoded as png.

  Parameters:
    `pltcmd` - the plot command
    `width` - the width of the image (in pixel)
    `height` - the height of the image (in pixel)
  Returns:
    the buffered image
  Throws:
    `Exception` - if something went wrong
  See Also:
    `showImage(String, BufferedImage)`, `ImageIO.write(java.awt.image.RenderedImage, java.lang.String, java.io.File)`

### plotToPDF

    public boolean plotToPDF(String pltcmd,
                             String fileName,
                             boolean overwriteExistingFile)
                      throws Exception

  Creates a pdf file from a given plot command.

  Parameters:
    `pltcmd` - the plot command
    `fileName` - the name of the pdf file
    `overwriteExistingFile` - if `true` the method is enabled to overwrite an existing file
  Returns:
    `true` if the plot is done
  Throws:
    `Exception` - if something went wrong

### plotToPDF

    public boolean plotToPDF(String pltcmd,
                             double width,
                             double height,
                             String fileName,
                             boolean overwriteExistingFile)
                      throws Exception

  Creates a pdf file with given dimension from a given plot command.

  Parameters:
    `pltcmd` - the plot command
    `width` - the width of the image
    `height` - the height of the image
    `fileName` - the name of the pdf file
    `overwriteExistingFile` - if `true` the method is enabled to overwrite an existing file
  Returns:
    `true` if the plot is done
  Throws:
    `Exception` - if something went wrong

### plotToTexFile

    public boolean plotToTexFile(String pltcmd,
                                 String fileName,
                                 boolean overwriteExistingFile)
                          throws Exception

  Creates a tex file from a given plot command.

  Parameters:
    `pltcmd` - the plot command
    `fileName` - the name of the tex file
    `overwriteExistingFile` - if `true` the method is enabled to overwrite an existing file
  Returns:
    `true` if the plot is done
  Throws:
    `Exception` - if something went wrong

### plotToTexFile

    public boolean plotToTexFile(String pltcmd,
                                 double width,
                                 double height,
                                 String fileName,
                                 boolean overwriteExistingFile)
                          throws Exception

  Creates a tex file with given dimension from a given plot command.

  Parameters:
    `pltcmd` - the plot command
    `width` - the width of the image
    `height` - the height of the image
    `fileName` - the name of the tex file
    `overwriteExistingFile` - if `true` the method is enabled to overwrite an existing file
  Returns:
    `true` if the plot is done
  Throws:
    `Exception` - if something went wrong

### voidEval

    public void voidEval(String cmd)
                  throws Exception

  Evaluates the `String` as R commands.

  Parameters:
    `cmd` - the `String` to be evaluated
  Throws:
    `Exception` - if something went wrong

### finalize

    protected void finalize()
                     throws Throwable

  Overrides:
    `finalize` in class `Object`
  Throws:
    `Throwable`

### showImage

    public static JFrame showImage(String title,
                                   BufferedImage img)
                            throws InterruptedException

  Enables you to show an image.

  Parameters:
    `title` - the title of the frame
    `img` - the image
  Returns:
    a frame showing the image
  Throws:
    `InterruptedException` - if the process is interrupted
  See Also:
    `showImage(String, BufferedImage, int)`

### showImage

    public static JFrame showImage(String title,
                                   BufferedImage img,
                                   int defaultCloseOperation)
                            throws InterruptedException

  Enables you to show an image.

  Parameters:
    `title` - the title of the frame
    `img` - the image
    `defaultCloseOperation` - the variable used to control the window-closing operation
  Returns:
    a frame showing the image
  Throws:
    `InterruptedException` - if the process is interrupted
  See Also:
    `WindowConstants`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD