public class RDataFrame extends REXPAbstract implements REXP
attributes, dataInconsistencyText, engine, indexExceptionText, names, noVariable, variable
Constructor and Description |
---|
RDataFrame(REngine engine)
Constructor
|
RDataFrame(REngine engine,
List<String> names,
List<String> rowNames,
List<List<?>> data,
String variable)
Constructor
|
RDataFrame(REngine engine,
Object[] datatypes,
int y)
Constructor
|
RDataFrame(REngine engine,
String[] names,
String[] rowNames,
List<List<?>> data,
String variable)
Constructor, used for autoconversion from rexp to data.frame.
|
Modifier and Type | Method and Description |
---|---|
protected void |
checkType(Object o) |
void |
checkX(int x)
Check if the index is into the data.frame length throws a
IndexOutOfBoundsException if the index is too big.
|
protected void |
checkY(int y)
Check if the index is into the data.frame length throws a
IndexOutOfBoundsException if the index is too big.
|
int[] |
dim() |
void |
exportCsv(File outputFile,
boolean rowNames,
boolean names)
Export the data.frame into csv format.
|
Object |
get(int x,
int y)
Method to get the object located at the [x,y] coordinates.
|
List<List<?>> |
getData()
Method to get the ArrayLists of the R data.frame.
|
void |
getFrom(String variable)
Method to get a data.frame from a variable in R.
|
String |
getRowName(int y)
Method to get the row name of the row index y+1 of the R data.frame.
|
List<String> |
getRowNames()
Method to get the names of the rows of the R data.frame
|
void |
importCsv(File inputFile,
boolean rowNames,
boolean names)
Import a dataframe form a csv file.
|
void |
importCsv(File inputFile,
boolean rowNames,
boolean names,
List<Object> importTypes)
Import a dataframe from a csv file.
|
void |
importCsv(File inputFile,
boolean rowNames,
boolean names,
Object importType)
Import a dataframe form a csv file.
|
void |
set(int x,
int y,
Boolean data) |
void |
set(int x,
int y,
Double data)
Method to set the value (x,y) to a Double value.
|
void |
set(int x,
int y,
Integer data) |
void |
set(int x,
int y,
String data) |
void |
setData(List<List<?>> data)
Method to assign the data of the R data.frame (there is no synchronizing
with R, use the commit() method to send data to R.
|
void |
setRowName(int x,
String rowName)
Method to assign the name of the ArrayList at the index x.
|
void |
setRowNames(List<String> rowNames)
Method to assign the names of the rows of the R data.frame
|
String |
toRString()
Method to export the data.frame in a String for evaluation in R.
|
String |
toString()
Method that returns a string representing the DataFrame.
|
checkVariable, getAttribute, getAttributes, getEngine, getName, getNames, getVariable, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttributes, setEngine, setName, setNames, setVariable
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getAttribute, getAttributes, getVariable, setAttribute, setAttributes
public RDataFrame(REngine engine)
engine
- the engine in which the data frame will be located.public RDataFrame(REngine engine, Object[] datatypes, int y) throws RException
engine
- the engine in which the data frame will be located.datatypes
- a table object determining the type of each column of
the data.frame.y
- the length of each vector that compound the data.frame.RException
- if a datatype is not supportedpublic RDataFrame(REngine engine, List<String> names, List<String> rowNames, List<List<?>> data, String variable) throws RException
engine
- the engine in which the data frame will be located.names
- names of the the data.frame columns.rowNames
- names of the data.frame rows.data
- the data of the data.framevariable
- the name of the data.frame in R.RException
- if an error occur while trying to
initializepublic RDataFrame(REngine engine, String[] names, String[] rowNames, List<List<?>> data, String variable)
engine
- the engine in which the data frame will be located.names
- names of the the data.frame columns.rowNames
- names of the data.frame rows.data
- the data of the data.framevariable
- the name of the data.frame in R.public List<String> getRowNames() throws RException
RException
- if an error occurs while getting back the names from R.IndexOutOfBoundsException
- when the row.names size get from R is bigger than the local
data size.public String getRowName(int y) throws RException
y
- index of the row (0 to n-1)RException
- if an error occurs while getting back the row name from R.public void setRowNames(List<String> rowNames) throws RException
rowNames
- a ArrayList containing the names of the rows of the R
data.frameRException
- if an error occur while in R.IndexOutOfBoundsException
- when the row names ArrayList is longer than the data.frame
lengthpublic void setRowName(int x, String rowName) throws RException
x
- index of the ArrayList (0 to n-1)rowName
- Name of the ArrayList.RException
- if an error occur while in R.IndexOutOfBoundsException
- when the index is out of the data.frame bounds.public String toRString() throws RException
toRString
in interface REXP
RException
- If no variable name is givenpublic void set(int x, int y, Double data) throws RException
x
- x coordinate (from 0 to size-1)y
- y coordinate (from 0 to size-1)data
- value to setRException
- if no variable name has been given to the data.frame or the
data type is not allowed at this location.public void set(int x, int y, Boolean data) throws RException
RException
public void set(int x, int y, String data) throws RException
RException
public void set(int x, int y, Integer data) throws RException
RException
public Object get(int x, int y) throws RException
x
- x coordinates (between 0 and size-1)y
- y coordinates (between 0 and size-1)RException
- if no variable name has been given to the data.frameIndexOutOfBoundsException
- if the x or y coordinates are not correct.public List<List<?>> getData()
public void setData(List<List<?>> data) throws RException
data
- a ArrayList of ArrayLists, containing each ArrayList of the R
data.frameRException
- if an error occur while trying to assign the valuespublic void getFrom(String variable) throws RException
getFrom
in interface REXP
variable
- name of the data.frame in RRException
public void exportCsv(File outputFile, boolean rowNames, boolean names) throws IOException
outputFile
- the file to writerowNames
- true/false to determine if the row names will be put on
the export.names
- true/false to determine if the column names will be put on
the export.IOException
- if cannot export to the outputFilepublic void importCsv(File inputFile, boolean rowNames, boolean names) throws IOException
inputFile
- Csv file to import.rowNames
- Does the csv file contains names of the rows.names
- Does the csv file contain names of the columns.IOException
- If cannot read the inputFilepublic void importCsv(File inputFile, boolean rowNames, boolean names, Object importType) throws IOException
inputFile
- Csv file to import.rowNames
- Does the csv file contains names of the rows.names
- Does the csv file contain names of the columns.importType
- Object of the class of the data imported (all the data have
the same type). (Supported types : String, Double and Integer)IOException
- if cannot read the inputFilepublic void importCsv(File inputFile, boolean rowNames, boolean names, List<Object> importTypes) throws IOException
inputFile
- Csv file to import.rowNames
- Does the csv file contains names of the rows.names
- Does the csv file contain names of the columns.importTypes
- ArrayList of Object of the class of the data imported (the
ArrayList match the data type of the columns). (Supported
types : String, Double and Integer)IOException
- if cannot read the inputFileprotected void checkY(int y)
y
- indexpublic void checkX(int x)
protected void checkType(Object o) throws RException
RException
public int[] dim() throws RException
RException
Copyright © 2006–2018 CodeLutin. All rights reserved.