org.rosuda.JGR
Class RController

java.lang.Object
  extended by org.rosuda.JGR.RController

public class RController
extends java.lang.Object

RController - implementations of an interface between JGR and Rengine, providing all needed functions for working with R.

Author:
Markus Helbig RoSuDa 2003 - 2005

Field Summary
static java.lang.Object dummy
          dummy object.
static java.lang.String TEMP_MATRIX_CONTENT_JGR
           
static java.lang.String TEMP_MATRIX_DIM_NAMES_JGR
           
static java.lang.String TEMP_VARIABLE_NAME
           
 
Constructor Summary
RController()
           
 
Method Summary
static java.lang.String addSlashes(java.lang.String str)
           
static java.lang.String commonWithPrefix(java.lang.String str1, java.lang.String str2)
          Compare to string and return the common prefix.
static java.lang.String[] completeCommand(java.lang.String partOfCmd)
          Show all posibilities to complete your given part of a command.
static java.lang.String[] completeFile(java.lang.String part)
          Completetion of a file (doesn't supports multiple fils yet).
static java.util.Vector createContent(RObject o, java.util.Collection c)
          Get the content of an RObject (list, data.frame, table, matrix).
static REXP createDataFrame(RList l, REXP rownames)
           
static RModel createRModel(java.lang.String sx, java.lang.String type)
          Create RModel (java-side) out of R
static RObject createRObject(java.lang.String sx, java.lang.String type, RObject parent, boolean b)
          Ceates an (java-side) out of R
static boolean export(SVarSet vs, java.lang.String type)
          Export an SVarSet to R.
static java.lang.String getCurrentPackages()
          Get R_DEFAULT_PACKAGES.
static java.lang.String[] getDefaultPackages()
          Get default packages as defined by R
static java.lang.String getFunHelpTip(java.lang.String s)
           
static java.lang.String[] getJgrDefaultPackages()
          Get default packages as defined by JGR (i.e.
static java.lang.String[] getKeyWords()
          Get all keywords for syntaxhighlighting.
static java.lang.String[] getObjects()
          Get object names used for syntaxhighlighting.
static java.lang.String getRContinue()
          Get R continue
static java.lang.String getRHome()
          Get R_HOME.
static java.lang.String[] getRLibs()
          Get R_LIBS.
static java.lang.String getRPrompt()
          Get R prompt
static java.lang.String getSummary(RObject o)
          Get summary of an RObject, R-command summary(...).
static boolean isValidSubsetExp(java.lang.String subset, java.lang.String dataName)
           
static void loadPackage(java.lang.String pack)
          loads a package.
static java.lang.String makeRStringVector(java.util.ArrayList lis)
           
static java.lang.String makeRStringVector(javax.swing.DefaultListModel mod)
           
static java.lang.String makeRStringVector(javax.swing.JList list)
           
static java.lang.String makeRStringVector(java.util.Vector mod)
           
static java.lang.String makeRVector(javax.swing.DefaultListModel mod)
           
static java.lang.String makeRVector(java.util.Vector vec)
           
static java.lang.String makeValidVariableName(java.lang.String var)
           
static void newFunction(RObject o)
           
static SVarSet newSet(RObject o)
          Create a new SVarSet of the specified RObject.
static SVar newVar(SVarSet cvs, java.lang.String name, double[] d)
          Construct a new numerical variable from supplied array of doubles.
static SVar newVar(SVarSet cvs, java.lang.String name, int[] d)
          Construct a new numerical variable from supplied array of integers.
static SVar newVar(SVarSet cvs, java.lang.String name, int[] ix, java.lang.String[] d)
           
static SVar newVar(SVarSet cvs, java.lang.String name, java.lang.String[] d)
          Construct a new categorical variable from supplied array of strings.
static void refreshObjects()
          Browse the workspace for objects and put them in JGR.MODELS, JGR.DATA, JGR.OTHER and JGR.FUNCTIONS. currently only these things which are provided by R-command: ls(pos=1).
static java.lang.Object[][] refreshPackages()
          Get information about all packages (loaded, undloaded, defaults ...).
static void requirePackages(java.lang.String rlist)
          load and attach packages defined by the string "pkg, pkg, ..."
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TEMP_MATRIX_DIM_NAMES_JGR

public static final java.lang.String TEMP_MATRIX_DIM_NAMES_JGR
See Also:
Constant Field Values

TEMP_MATRIX_CONTENT_JGR

public static final java.lang.String TEMP_MATRIX_CONTENT_JGR
See Also:
Constant Field Values

TEMP_VARIABLE_NAME

public static final java.lang.String TEMP_VARIABLE_NAME
See Also:
Constant Field Values

dummy

public static java.lang.Object dummy
dummy object.

Constructor Detail

RController

public RController()
Method Detail

getRHome

public static java.lang.String getRHome()
Get R_HOME.

Returns:
R_HOME path

getRLibs

public static java.lang.String[] getRLibs()
Get R_LIBS.

Returns:
R_LIBS paths

getRPrompt

public static java.lang.String getRPrompt()
Get R prompt

Returns:
prompt

getRContinue

public static java.lang.String getRContinue()
Get R continue

Returns:
continue

getCurrentPackages

public static java.lang.String getCurrentPackages()
Get R_DEFAULT_PACKAGES.

Returns:
default packages

getDefaultPackages

public static java.lang.String[] getDefaultPackages()
Get default packages as defined by R

Returns:
R default packages

getJgrDefaultPackages

public static java.lang.String[] getJgrDefaultPackages()
Get default packages as defined by JGR (i.e. R's default packages plus auto-loaded packages from JGR preferences)

Returns:
JGR default packages

requirePackages

public static void requirePackages(java.lang.String rlist)
load and attach packages defined by the string "pkg, pkg, ..."


loadPackage

public static void loadPackage(java.lang.String pack)
loads a package. If it isn't installed, it is loaded from CRAN

Parameters:
pack -

completeCommand

public static java.lang.String[] completeCommand(java.lang.String partOfCmd)
Show all posibilities to complete your given part of a command.

Parameters:
partOfCmd - part which you want to complete
Returns:
possible completions

completeFile

public static java.lang.String[] completeFile(java.lang.String part)
Completetion of a file (doesn't supports multiple fils yet).

Parameters:
part - of file to complete
Returns:
file

addSlashes

public static java.lang.String addSlashes(java.lang.String str)

makeValidVariableName

public static java.lang.String makeValidVariableName(java.lang.String var)

makeRStringVector

public static java.lang.String makeRStringVector(java.util.ArrayList lis)

makeRStringVector

public static java.lang.String makeRStringVector(javax.swing.JList list)

makeRStringVector

public static java.lang.String makeRStringVector(javax.swing.DefaultListModel mod)

makeRStringVector

public static java.lang.String makeRStringVector(java.util.Vector mod)

makeRVector

public static java.lang.String makeRVector(java.util.Vector vec)

makeRVector

public static java.lang.String makeRVector(javax.swing.DefaultListModel mod)

isValidSubsetExp

public static boolean isValidSubsetExp(java.lang.String subset,
                                       java.lang.String dataName)

getKeyWords

public static java.lang.String[] getKeyWords()
Get all keywords for syntaxhighlighting.

Returns:
keywords

getObjects

public static java.lang.String[] getObjects()
Get object names used for syntaxhighlighting.

Returns:
objects

refreshObjects

public static void refreshObjects()
Browse the workspace for objects and put them in JGR.MODELS, JGR.DATA, JGR.OTHER and JGR.FUNCTIONS. currently only these things which are provided by R-command: ls(pos=1).


refreshPackages

public static java.lang.Object[][] refreshPackages()
Get information about all packages (loaded, undloaded, defaults ...).

Returns:
package information

createContent

public static java.util.Vector createContent(RObject o,
                                             java.util.Collection c)
Get the content of an RObject (list, data.frame, table, matrix).

Parameters:
o - RObject
c - all found objects are collected in c (currently disabled)
Returns:
vector of RObject

createRObject

public static RObject createRObject(java.lang.String sx,
                                    java.lang.String type,
                                    RObject parent,
                                    boolean b)
Ceates an (java-side) out of R

Parameters:
sx - name
type - type
parent - parent
b - names(..) provides real names or not
Returns:
new RObject

createRModel

public static RModel createRModel(java.lang.String sx,
                                  java.lang.String type)
Create RModel (java-side) out of R

Parameters:
sx - name
type - type (currently only lm and glm is supported
Returns:
new RModel

getFunHelpTip

public static java.lang.String getFunHelpTip(java.lang.String s)

getSummary

public static java.lang.String getSummary(RObject o)
Get summary of an RObject, R-command summary(...).

Parameters:
o - RObject
Returns:
summary of object

newFunction

public static void newFunction(RObject o)

newSet

public static SVarSet newSet(RObject o)
Create a new SVarSet of the specified RObject.

Parameters:
o - RObject which should be parsed into the dataset
Returns:
new dataset

newVar

public static SVar newVar(SVarSet cvs,
                          java.lang.String name,
                          double[] d)
Construct a new numerical variable from supplied array of doubles.

Parameters:
name - variable name
d - array of doubles
Returns:
SVar

newVar

public static SVar newVar(SVarSet cvs,
                          java.lang.String name,
                          int[] d)
Construct a new numerical variable from supplied array of integers.

Parameters:
name - variable name
d - array of integers
Returns:
SVar

newVar

public static SVar newVar(SVarSet cvs,
                          java.lang.String name,
                          java.lang.String[] d)
Construct a new categorical variable from supplied array of strings.

Parameters:
name - variable name
d - array of strings
Returns:
SVar

newVar

public static SVar newVar(SVarSet cvs,
                          java.lang.String name,
                          int[] ix,
                          java.lang.String[] d)

export

public static boolean export(SVarSet vs,
                             java.lang.String type)
Export an SVarSet to R.

Parameters:
vs - dataset
type - R-class of RObject behind vs
Returns:
true if successful, false if not

createDataFrame

public static REXP createDataFrame(RList l,
                                   REXP rownames)
                            throws REXPMismatchException
Throws:
REXPMismatchException

commonWithPrefix

public static java.lang.String commonWithPrefix(java.lang.String str1,
                                                java.lang.String str2)
Compare to string and return the common prefix.

Parameters:
str1 - String 1
str2 - String 2
Returns:
common prefix