Hi all,<div><br></div><div>Thank you so much for your valuable input. I can definitely store list of columns and keeps appending to the table using STL list. But my question is that what kind of abstraction for each column type I should use? In STL list, But that will mean I have to be able to construct STL list with dynamic type depending on the columns in my returning query. Can I make all of the columns into, says, list<SEXP> for abstraction purpose? Then just cast it into corresponding type when creating data.frame to return back to R? Any snippet to demonstrate the idea would be appreciated. Thank you!</div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Nov 26, 2012 at 4:00 PM, John Merrill <span dir="ltr"><<a href="mailto:john.merrill@gmail.com" target="_blank">john.merrill@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">There's a small issue with that -- if your columns contain any<br>
character lists, then those columns wind up being coerced into factors<br>
by as.data.frame (inside the constructor).  You can work around that<br>
by either setting the default value of the stringsAsFactors option to<br>
FALSE, and then resetting it after you create the data frame, or by<br>
setting the "AsIs" class attribute on the column and then removing it<br>
after you create the dataframe.  Neither of these is pretty, but they<br>
both work.<br>
<div><div class="h5"><br>
On Mon, Nov 26, 2012 at 12:55 PM, Dirk Eddelbuettel <<a href="mailto:edd@debian.org">edd@debian.org</a>> wrote:<br>
><br>
> On 26 November 2012 at 12:41, Davor Cubranic wrote:<br>
> | On 2012-11-23, at 1:36 PM, Robert A'gata wrote:<br>
> |<br>
> | > Inside onEventA, I'd like to be able to create a blank data.frame or<br>
> | > list with zero length vector. Once my data frame or list object is<br>
> | > constructed, I'd like to append a new row to it each time onEventB is<br>
> | > invoked. How can I achieve this in Rcpp? Thank you.<br>
> |<br>
> | Can you possibly stay in STL and keep rows in std::list, and only construct a Rcpp::DataFrame before you return to R?<br>
><br>
> Seconded -- meant to reply as well and got side-tracked.<br>
><br>
> That's why I once did to gather data from a tick data plant. I just grew<br>
> everything (on callbacks from the ticker database system) in a stateful C++<br>
> class, and then transformed into Rcpp types before returning the query to R.<br>
><br>
> I knew how many columns I'd get at the beginning of the result set, and could<br>
> then grew them as results came in.  Was a nice solution and better than what<br>
> the vendor offered via ODBC :)<br>
><br>
> Dirk<br>
><br>
> --<br>
> Dirk Eddelbuettel | <a href="mailto:edd@debian.org">edd@debian.org</a> | <a href="http://dirk.eddelbuettel.com" target="_blank">http://dirk.eddelbuettel.com</a><br>
</div></div>> _______________________________________________<br>
> Rcpp-devel mailing list<br>
> <a href="mailto:Rcpp-devel@lists.r-forge.r-project.org">Rcpp-devel@lists.r-forge.r-project.org</a><br>
> <a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a><br>
_______________________________________________<br>
Rcpp-devel mailing list<br>
<a href="mailto:Rcpp-devel@lists.r-forge.r-project.org">Rcpp-devel@lists.r-forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a><br>
</blockquote></div><br></div>