Hi, Using Rcpp through inline.
I want to return a matrix, but I don't know the size beforehand. (My code loops through a large data set accumulating certain statistics.) With a NumericVector, I can use push_back() to just add values to the end of the vector as they occur. Is there similar functionality for a NumericMatrix? Alternately, I could store all my generated statistics in several vectors (6-7) and then, when complete with my loop, glue them together into a matrix. But, this seems inefficient. Here is a rough example of what I'm trying to do. ------------------------------ int n = inputData.size(); Rcpp::NumericMatrix output; for(int i=0; i != n; i++){ // generate some stats with a lot of code not shown foo = mean(stuff); bar = min(stuff); baz = max(stuff); // etc... output.push_back(foo, bar, baz); ) return output; ------------------------------- -- Noah Silverman UCLA Department of Statistics 8117 Math Sciences Building #8208 Los Angeles, CA 90095
_______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel