|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectorg.rosuda.REngine.REXP
public class REXP
Basic class representing an object of any type in R. Each type in R in represented by a specific subclass.
This class defines basic accessor methods (asXXX), type check methods (isXXX), gives access to attributes (getAttribute(java.lang.String), hasAttribute(java.lang.String)) as well as several convenience methods. If a given method is not applicable to a particular type, it will throw the REXPMismatchException exception.
This root class will throw on any accessor call and returns false for all type methods. This allows subclasses to override accessor and type methods selectively.
| Field Summary | |
|---|---|
protected REXPList |
attr
attribute list. |
static int |
maxDebugItems
specifies how many items of a vector or list will be displayed in toDebugString() |
| Constructor Summary | |
|---|---|
REXP()
public root contrsuctor, same as new REXP(null) |
|
REXP(REXPList attr)
public root constructor |
|
| Method Summary | |
|---|---|
REXPList |
_attr()
this method allows a limited access to object's attributes - getAttribute(java.lang.String) should be used instead to access specific attributes!. |
byte[] |
asBytes()
returns the contents as an array of bytes (if supported by the represented object) |
double |
asDouble()
convenience method corresponding to asDoubles()[0] |
double[][] |
asDoubleMatrix()
returns the content of the REXP as a matrix of doubles (2D-array: m[rows][cols]). |
double[] |
asDoubles()
returns the contents as an array of doubles (if supported by the represented object) |
RFactor |
asFactor()
returns the contents as a factor (if supported by the represented object) |
int |
asInteger()
convenience method corresponding to asIntegers()[0] |
int[] |
asIntegers()
returns the contents as an array of integers (if supported by the represented object) |
RList |
asList()
returns the contents as a (named) list (if supported by the represented object) |
java.lang.Object |
asNativeJavaObject()
attempt to represent the REXP by a native Java object and return it. |
java.lang.String |
asString()
convenience method corresponding to asStrings()[0] |
java.lang.String[] |
asStrings()
returns the contents as an array of Strings (if supported by the represented object) |
static REXP |
createDataFrame(RList l)
creates a data frame object from a list object using integer row names |
int[] |
dim()
returns dimensions of the object (as determined by the " dim" attribute) |
REXP |
getAttribute(java.lang.String name)
retrieve an attribute of the given name from this object |
boolean |
hasAttribute(java.lang.String name)
checks whether this obejct has a given attribute |
boolean |
inherits(java.lang.String klass)
determines whether this object inherits from a given class in the same fashion as the inherits() function in R does (i.e. |
boolean |
isComplex()
check whether the REXP object is a complex vector |
boolean |
isEnvironment()
check whether the REXP object is an environment |
boolean |
isExpression()
check whether the REXP object is an expression vector |
boolean |
isFactor()
check whether the REXP object is a factor |
boolean |
isInteger()
check whether the REXP object is an integer vector |
boolean |
isLanguage()
check whether the REXP object is a language object |
boolean |
isList()
check whether the REXP object is a list (either generic vector or a pairlist - i.e. |
boolean |
isLogical()
check whether the REXP object is a logical vector |
boolean[] |
isNA()
returns a boolean vector of the same length as this vector with true for NA values and false for any other values |
boolean |
isNull()
check whether the REXP object is NULL |
boolean |
isNumeric()
check whether the REXP object is a numeric vector |
boolean |
isPairList()
check whether the REXP object is a pair-list |
boolean |
isRaw()
check whether the REXP object is a raw vector |
boolean |
isRecursive()
check whether the REXP object is a recursive obejct |
boolean |
isReference()
check whether the REXP object is a reference to an R object |
boolean |
isString()
check whether the REXP object is a character vector (string) |
boolean |
isSymbol()
check whether the REXP object is a symbol |
boolean |
isVector()
check whether the REXP object is a vector |
int |
length()
returns the length of a vector object. |
java.lang.String |
toDebugString()
returns representation that it useful for debugging (e.g. |
java.lang.String |
toString()
returns a string description of the object |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected REXPList attr
public static int maxDebugItems
toDebugString()
| Constructor Detail |
|---|
public REXP()
public REXP(REXPList attr)
attr - attribute list object (can be null| Method Detail |
|---|
public boolean isString()
REXP object is a character vector (string)
true if the receiver is a character vector, false otherwisepublic boolean isNumeric()
REXP object is a numeric vector
true if the receiver is a numeric vector, false otherwisepublic boolean isInteger()
REXP object is an integer vector
true if the receiver is an integer vector, false otherwisepublic boolean isNull()
REXP object is NULL
true if the receiver is NULL, false otherwisepublic boolean isFactor()
REXP object is a factor
true if the receiver is a factor, false otherwisepublic boolean isList()
REXP object is a list (either generic vector or a pairlist - i.e. asList() will succeed)
true if the receiver is a generic vector or a pair-list, false otherwisepublic boolean isPairList()
REXP object is a pair-list
true if the receiver is a pair-list, false otherwisepublic boolean isLogical()
REXP object is a logical vector
true if the receiver is a logical vector, false otherwisepublic boolean isEnvironment()
REXP object is an environment
true if the receiver is an environment, false otherwisepublic boolean isLanguage()
REXP object is a language object
true if the receiver is a language object, false otherwisepublic boolean isExpression()
REXP object is an expression vector
true if the receiver is an expression vector, false otherwisepublic boolean isSymbol()
REXP object is a symbol
true if the receiver is a symbol, false otherwisepublic boolean isVector()
REXP object is a vector
true if the receiver is a vector, false otherwisepublic boolean isRaw()
REXP object is a raw vector
true if the receiver is a raw vector, false otherwisepublic boolean isComplex()
REXP object is a complex vector
true if the receiver is a complex vector, false otherwisepublic boolean isRecursive()
REXP object is a recursive obejct
true if the receiver is a recursive object, false otherwisepublic boolean isReference()
REXP object is a reference to an R object
true if the receiver is a reference, false otherwise
public java.lang.String[] asStrings()
throws REXPMismatchException
REXPMismatchException
public int[] asIntegers()
throws REXPMismatchException
REXPMismatchException
public double[] asDoubles()
throws REXPMismatchException
REXPMismatchException
public byte[] asBytes()
throws REXPMismatchException
REXPMismatchException
public RList asList()
throws REXPMismatchException
REXPMismatchException
public RFactor asFactor()
throws REXPMismatchException
REXPMismatchException
public java.lang.Object asNativeJavaObject()
throws REXPMismatchException
int[1] and not Integer).
REXPMismatchException
public int length()
throws REXPMismatchException
dim() for retrieving matrix and multidimentional-array dimensions).
REXPMismatchException - if this is not a vector object
public boolean[] isNA()
throws REXPMismatchException
true for NA values and false for any other values
true for NA values and false for any other values
REXPMismatchException - if this is not a vector object
public int asInteger()
throws REXPMismatchException
asIntegers()[0]
asInteger()
REXPMismatchException
public double asDouble()
throws REXPMismatchException
asDoubles()[0]
asDoubles()
REXPMismatchException
public java.lang.String asString()
throws REXPMismatchException
asStrings()[0]
asStrings()
REXPMismatchExceptionpublic REXP getAttribute(java.lang.String name)
name - attribute name
null if the attribute does not existpublic boolean hasAttribute(java.lang.String name)
name - attribute name
true if the attribute exists, false otherwisepublic int[] dim()
dim" attribute)
null if the object has no dimension attributepublic boolean inherits(java.lang.String klass)
inherits() function in R does (i.e. ignoring S4 inheritance)
klass - class name
true if this object is of the class klass, false otherwisepublic REXPList _attr()
getAttribute(java.lang.String) should be used instead to access specific attributes!. Note that the attr attribute should never be used directly incase the REXP implements a lazy access (e.g. via a reference)
null if the object has no attributespublic java.lang.String toString()
toString in class java.lang.ObjectasString() for accessing string REXPs)public java.lang.String toDebugString()
maxDebugItems)
public double[][] asDoubleMatrix()
throws REXPMismatchException
Matrix m=new Matrix(c.eval("matrix(c(1,2,3,4,5,6),2,3)").asDoubleMatrix());
null if the contents is no 2-dimensional matrix of doubles
REXPMismatchException
public static REXP createDataFrame(RList l)
throws REXPMismatchException
l - a (named) list of vectors (REXPVector subclasses), each element corresponds to a column and all elements must have the same length
REXPMismatchException - if the list is empty or any of the elements is not a vector
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||