Hi,<br><br>I am at my wits end trying to create a dataframe from a list of values that I have. here's the code<br><br><font class="Apple-style-span" face="'courier new', monospace"> try{<br> int size = argTypes.getColumnCount();<br>
std::vector<std::string> nameVec(size);<br> std::vector<int> lenVec(size);<br> std::vector<int> scaleVec(size);<br> <br> for (size_t i = 0; i < size; ++i) {<br> //get the datatype<br>
vt = argTypes.getColumnType(i);<br> BaseDataOID BDOid = vt.getTypeOid();<br><br> //convert the Oid to string name<br> std::string columnType = Oid2String(BDOid);<br> <br>
//get the length for string types, precision for time and numerics and scale for numerics<br> int length = 0;<br> int scale= 0;<br> getTypeLength(vt, length, scale);<br> <br>
//add the values to the vectors<br> nameVec.push_back(columnType);<br> lenVec.push_back(length);<br> scaleVec.push_back(scale); <br> }<br> <br> //create the dataframe<br>
Rcpp::List df = Rcpp::List::create(Rcpp::Named("datatype",nameVec),<br> Rcpp::Named("length",lenVec),<br> Rcpp::Named("scale",scaleVec));<br>
Rcpp::DataFrame df_final = Rcpp::DataFrame::create(df);<br> return df_final;<br><br> }<br> catch(std::exception &e) {<br> throw;<br> }</font><br><br><br>The std::vectors are created fine but the list is not created <br>
(gdb) p R_PV(df)<br>$3 = 0<br><br><br>I have tried a lot of variation like creating the dataframe directly without first creating the list. Nothing seems to be working. <br><br><br><br>Thanks<br>Pratibha