libRDataFrame  0.815
A library with R style datatypes and associated utilities
 All Classes Files Functions Variables Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
dataframe Class Reference
Collaboration diagram for dataframe:
Collaboration graph
[legend]

Public Member Functions

 dataframe (node varNode)
 
 dataframe (std::string s, int r, int c)
 
std::vector< nodegetDataframe ()
 
std::string getDataFrameName ()
 
void * getObs (int rowNumber)
 
std::vector< std::string > getColTypes ()
 
std::vector< std::string > getColNames ()
 
void setColTypes (std::vector< std::string > cTypes)
 
void setColNames (std::vector< std::string > cNames)
 
node getNode (std::string vName="", int vNumber=0)
 
std::vector< std::string > getRangeOfRows (int start, int ending)
 
void * getDataRange (int r1, int c1, int r2, int c2)
 
void addObsRow (void *obsRow)
 
void setDfName (std::string)
 
void setNode (node varNode, int vNumber)
 
void setDataframe (std::vector< node > dframe)
 
void convertDfToVStrings (dataframe df)
 
std::vector< std::string > readRowsSDS (std::vector< std::vector< std::string > > strDStruct, int nCSVRows, int colNumber)
 
void convertParsedVStrtoDf (std::vector< std::vector< std::string > > parsedVVS)
 
void loadFromCSV (std::string csvFName, bool header, std::vector< std::string > strVarTypes)
 
std::vector< std::vector
< std::string > > 
makeDataFrame (std::vector< std::vector< std::string > > intStrDStruct)
 
void saveToCSV (std::string csvFName)
 
void convertCSVtoDF (std::vector< std::vector< std::string > > strCSVStruct, int nCSVRows, int nCSVCols)
 
void displayDataframe ()
 
void displayNodeData (int position=0, std::string varName="")
 
std::string toStringStream ()
 

Protected Member Functions

std::vector< std::string > createTypesVector ()
 
void createObsDataframe ()
 
boost::any createObsTuple ()
 

Protected Attributes

int nrows
 
int ncols
 
std::string dfName
 
node varsGrp
 
std::vector< nodedf
 
std::vector< std::vector
< std::string > > 
fetchedStrDataStruct
 
std::vector< std::string > colNames
 
std::vector< std::string > colTypes
 
void * obsDataFrame = nullptr
 
std::vector< std::string > obsRowNames
 

Constructor & Destructor Documentation

dataframe::dataframe ( node  varNode)

. . . a constructor with the first variable/Node initializes rows and columns to (0,0)

Member Function Documentation

void dataframe::addObsRow ( void *  obsRow)

add a row of observations to the dataframe structure tuples,

Parameters
obsRowa pointer to the tuple of observations to add
Returns
none (void)
void dataframe::convertCSVtoDF ( std::vector< std::vector< std::string > >  strCSVStruct,
int  nCSVRows,
int  nCSVCols 
)

build a dataframe / Class of vector of variable columns of types string as vector collection of contents from parsed strings of a specific observation fields.

read each CSV row, into a column vector, put pointer5 to vector in a node, put node in the dataframe

void dataframe::convertParsedVStrtoDf ( std::vector< std::vector< std::string > >  parsedVVS)

convert a parsed vector of strings to a dataframe of nodes

void dataframe::createObsDataframe ( )
protected

create a table of observations from the dataframe listing variable observation(s) (values) as tuples,

Parameters
none
Returns
none (void)
boost::any dataframe::createObsTuple ( )
protected

create a tuple from a specific row of variables elements, an internal helper function for the dataframe

Parameters
nrowthe row to read accross the table
Returns
obsRow a tuple (pointer to) with the data by type from the line
vector< string > dataframe::createTypesVector ( )
protected

Dataframe class methods helper methods (internal/protected) converters public may be used internally and externally getters - public setters - public utility methods public (usually used externally) displayers - publiccreate a vector of variable (column) types as response to query of dataframe

void dataframe::displayDataframe ( )

display the dataframe as a table or wxGrid structure,

Parameters
none
Returns
none (void)
void dataframe::displayNodeData ( int  position = 0,
std::string  varName = "" 
)

display the node/variable of the dataframe,

Parameters
varNamevariable to display by name
varNumbervariable number to display
Returns
none (void)
vector< string > dataframe::getColNames ( )

get listing of variable names (column names) of the dataframe.

Parameters
null
Returns
a vector<string> the variable names as a vector of strings
vector< node > dataframe::getDataframe ( )

get the whole dataframe as a vector of nodes

Parameters
none
Returns
dataframe, ie. a vector of nodes which is the dataframe itself
string dataframe::getDataFrameName ( )

get the dataframe name,

Parameters
none
Returns
a string with the dataframe's name
void * dataframe::getDataRange ( int  r1,
int  c1,
int  r2,
int  c2 
)

get data range or block from one or more variables (columns) of the dataframe structure,

Parameters
r1,c1,r2,c2- the rows and columns to fetch *
Returns
a pointer to a block of values for the range selected
node dataframe::getNode ( std::string  vName = "",
int  vNumber = 0 
)

get a variable with meta-data and the dataset stored in it. This is a node.

Parameters
vNamethe node or variable name to fetch, default NULL or
vNumberthe node or variable number to fetch default 0
Returns
the variable node
void * dataframe::getObs ( int  rowNumber)

get observations from a row of the dataframe structure observation(s) as tuples,

Parameters
therow to fetch
Returns
pointer to tuple containing variable values in the row
vector< string > dataframe::getRangeOfRows ( int  start,
int  ending 
)

get a range of rows, ie. observation(s) as tuples,

Parameters
therows to fetch
Returns
a vector<tuple>, the variable values in the rows (as a pointer to a vector of tuple)
void dataframe::loadFromCSV ( std::string  csvFName,
bool  header,
std::vector< std::string >  strVarTypes 
)

load data from a CSV into the dataframe,

Parameters
csvFNamename and path of the file to read and import the data from.
headera boolean indicating if the first row of CSV contains column names.
Returns
none (void)
vector< string > dataframe::readRowsSDS ( std::vector< std::vector< std::string > >  strDStruct,
int  nCSVRows,
int  colNumber 
)

readRowsCSV, read a variable element from each row and construct a column vector of a single variable's observation set

Parameters
strDStructCSV derived string data structure to read from
nRnumber of row s (ie. elements ) to be read into the column vector
colNumberthe variable number (column) of analogous observations
Returns
varVector the vector of variable readings (observations)
void dataframe::saveToCSV ( std::string  csvFName)

save the dataframe contents (with or without a header line) to a CSV file,

Parameters
csvFNameto save to (defaults to 'datafile').
headera boolean to say wther to include column names.
Returns
none (void)
void dataframe::setDataframe ( std::vector< node dframe)

reset dataframe from external vector<node> an already constructed vector of nodes (variables)

Parameters
dframean intact vector of nodes from any source
void dataframe::setNode ( node  varNode,
int  vNumber 
)

add a new Node/variable or (re)set the contents of a Node or variable, Consider whether this functionality should be split further between variable data edit, Node content resets and node add.

Parameters
NodevarNode with all the variable meta-data and data,
vNumberthe position number of the variable. if exists reset, if new add
Returns
none (void)
string dataframe::toStringStream ( )

convert the full dataframe contents to a string stream,

Parameters
none
Returns
none (void)

The documentation for this class was generated from the following files: