org.rosuda.REngine
Class REXPFactor

java.lang.Object
  extended by org.rosuda.REngine.REXP
      extended by org.rosuda.REngine.REXPVector
          extended by org.rosuda.REngine.REXPInteger
              extended by org.rosuda.REngine.REXPFactor

public class REXPFactor
extends REXPInteger

REXPFactor represents a factor in R. It is an integer vector with levels for each contained category.


Field Summary
 
Fields inherited from class org.rosuda.REngine.REXPInteger
NA, payload
 
Fields inherited from class org.rosuda.REngine.REXP
attr, maxDebugItems
 
Constructor Summary
REXPFactor(int[] ids, java.lang.String[] levels)
          create a new factor REXP
REXPFactor(int[] ids, java.lang.String[] levels, REXPList attr)
          create a new factor REXP
REXPFactor(RFactor factor)
          create a new factor REXP from an existing RFactor
REXPFactor(RFactor factor, REXPList attr)
          create a new factor REXP from an existing RFactor
 
Method Summary
 RFactor asFactor()
          return the contents as a factor - the factor is guaranteed to have index base 1
 java.lang.Object asNativeJavaObject()
          attempt to represent the REXP by a native Java object and return it.
 java.lang.String[] asStrings()
          returns the contents of this vector as strings
 boolean isFactor()
          check whether the REXP object is a factor
 java.lang.String toString()
          returns a string description of the object
 
Methods inherited from class org.rosuda.REngine.REXPInteger
asDoubles, asIntegers, isInteger, isNA, isNA, isNumeric, length, toDebugString
 
Methods inherited from class org.rosuda.REngine.REXPVector
isVector
 
Methods inherited from class org.rosuda.REngine.REXP
_attr, asBytes, asDouble, asDoubleMatrix, asInteger, asList, asString, createDataFrame, createDoubleMatrix, dim, getAttribute, hasAttribute, inherits, isComplex, isEnvironment, isExpression, isLanguage, isList, isLogical, isNull, isPairList, isRaw, isRecursive, isReference, isString, isSymbol
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

REXPFactor

public REXPFactor(int[] ids,
                  java.lang.String[] levels)
create a new factor REXP

Parameters:
ids - indices (one-based!)
levels - levels

REXPFactor

public REXPFactor(int[] ids,
                  java.lang.String[] levels,
                  REXPList attr)
create a new factor REXP

Parameters:
ids - indices (one-based!)
levels - levels
attr - attributes

REXPFactor

public REXPFactor(RFactor factor)
create a new factor REXP from an existing RFactor

Parameters:
factor - factor object (can be of any index base, the contents will be pulled with base 1)

REXPFactor

public REXPFactor(RFactor factor,
                  REXPList attr)
create a new factor REXP from an existing RFactor

Parameters:
factor - factor object (can be of any index base, the contents will be pulled with base 1)
attr - attributes
Method Detail

isFactor

public boolean isFactor()
Description copied from class: REXP
check whether the REXP object is a factor

Overrides:
isFactor in class REXP
Returns:
true if the receiver is a factor, false otherwise

asFactor

public RFactor asFactor()
return the contents as a factor - the factor is guaranteed to have index base 1

Overrides:
asFactor in class REXP
Returns:
the contents as a factor

asStrings

public java.lang.String[] asStrings()
Description copied from class: REXPInteger
returns the contents of this vector as strings

Overrides:
asStrings in class REXPInteger

asNativeJavaObject

public java.lang.Object asNativeJavaObject()
Description copied from class: REXP
attempt to represent the REXP by a native Java object and return it. Note that this may lead to loss of information (e.g., factors may be returned as a string array) and attributes are ignored. Not all R types can be converted to native Java objects. Also note that R has no concept of scalars, so vectors of length 1 will always be returned as an arrays (i.e., int[1] and not Integer).

Overrides:
asNativeJavaObject in class REXPInteger

toString

public java.lang.String toString()
Description copied from class: REXP
returns a string description of the object

Overrides:
toString in class REXPVector
Returns:
string describing the object - it can be of an arbitrary form and used only for debugging (do not confuse with REXP.asString() for accessing string REXPs)