libRDataFrame  0.815
A library with R style datatypes and associated utilities
 All Classes Files Functions Variables Pages
dataframe.hpp
1 #ifndef DATAFRAME_HPP_INCLUDED
2 #define DATAFRAME_HPP_INCLUDED
3 
4 #include <cstdio>
5 #include <cstdlib>
6 #include <cctype>
7 #include <iostream>
8 #include <ostream>
9 #include <fstream>
10 #include <sstream>
11 #include <string>
12 #include <vector>
13 #include <map>
14 #include <tuple>
15 #include <algorithm>
16 #include <typeinfo>
17 #include <cxxabi.h>
18 #include <array>
19 #include <initializer_list>
20 #include <boost/any.hpp>
21 
22 #include "utilCSV.hpp"
23 #include "node.hpp"
24 
25 
26 
27 class dataframe {
28 protected:
29  int nrows;
30  int ncols;
31  std::string dfName;
32  node varsGrp;
33  std::vector<node> df;
34  std::vector<std::vector<std::string> > fetchedStrDataStruct;
35  std::vector<std::string> colNames;
36  std::vector<std::string> colTypes;
37 
38  void* obsDataFrame = nullptr;
39  std::vector<std::string> obsRowNames;
40 public:
41 
42  dataframe();
43  dataframe(node varNode);
44  dataframe(std::string s, int r, int c);
45 protected:
46  std::vector<std::string> createTypesVector();
47  void createObsDataframe();
48  boost::any createObsTuple();
49 
50 public:
51  std::vector<node> getDataframe();
52  std::string getDataFrameName();
53  void* getObs(int rowNumber);
54  std::vector<std::string>getColTypes();
55  std::vector<std::string>getColNames();
56  void setColTypes(std::vector<std::string> cTypes);
57  void setColNames(std::vector<std::string> cNames);
58  node getNode(std::string vName= "", int vNumber = 0);
59  std::vector<std::string> getRangeOfRows(int start, int ending);
60  void* getDataRange(int r1,int c1,int r2, int c2);
61  void addObsRow(void* obsRow);
62  void setDfName(std::string);
63  void setNode(node varNode, int vNumber);
64  void setDataframe(std::vector<node> dframe);
65  void convertDfToVStrings(dataframe df);
66  std::vector<std::string> readRowsSDS(std::vector<std::vector<std::string> > strDStruct,int nCSVRows, int colNumber);
67  void convertParsedVStrtoDf(std::vector< std::vector<std::string> > parsedVVS);
68  void loadFromCSV(std::string csvFName, bool header, std::vector<std::string> strVarTypes);
69  std::vector<std::vector<std::string> > makeDataFrame (std::vector<std::vector<std::string> > intStrDStruct);
70  void saveToCSV(std::string csvFName);
71  void convertCSVtoDF(std::vector<std::vector<std::string> > strCSVStruct, int nCSVRows, int nCSVCols);
72  void displayDataframe();
73  void displayNodeData(int position=0, std::string varName="");
74  std::string toStringStream();
75 };
76 
77 
78 
79 #endif // DATAFRAME_HPP_INCLUDED
void * getObs(int rowNumber)
Definition: dataframe.cpp:136
std::vector< std::string > getColNames()
Definition: dataframe.cpp:182
void setNode(node varNode, int vNumber)
Definition: dataframe.cpp:214
void displayNodeData(int position=0, std::string varName="")
Definition: dataframe.cpp:362
void setDataframe(std::vector< node > dframe)
Definition: dataframe.cpp:224
void createObsDataframe()
Definition: dataframe.cpp:101
Definition: node.hpp:25
void * getDataRange(int r1, int c1, int r2, int c2)
Definition: dataframe.cpp:171
std::vector< std::string > getRangeOfRows(int start, int ending)
Definition: dataframe.cpp:160
std::vector< std::string > readRowsSDS(std::vector< std::vector< std::string > > strDStruct, int nCSVRows, int colNumber)
Definition: dataframe.cpp:284
void saveToCSV(std::string csvFName)
Definition: dataframe.cpp:338
std::vector< std::string > createTypesVector()
Definition: dataframe.cpp:89
std::string toStringStream()
Definition: dataframe.cpp:370
void convertParsedVStrtoDf(std::vector< std::vector< std::string > > parsedVVS)
Definition: dataframe.cpp:245
void addObsRow(void *obsRow)
Definition: dataframe.cpp:195
std::vector< node > getDataframe()
Definition: dataframe.cpp:118
void loadFromCSV(std::string csvFName, bool header, std::vector< std::string > strVarTypes)
Definition: dataframe.cpp:255
void displayDataframe()
Definition: dataframe.cpp:346
node getNode(std::string vName="", int vNumber=0)
Definition: dataframe.cpp:149
boost::any createObsTuple()
Definition: dataframe.cpp:109
void convertCSVtoDF(std::vector< std::vector< std::string > > strCSVStruct, int nCSVRows, int nCSVCols)
Definition: dataframe.cpp:306
std::string getDataFrameName()
Definition: dataframe.cpp:126
Definition: dataframe.hpp:27