Re: [Rcpp-devel] Push back to a matrix (Noah Silverman)

2011-09-05 Thread Silkworth,David J.
Looking at your pseudo code it appears that you know how many columns are required in your matrix before run time. This situation lends itself well to generating the columns of your matrix as vectors as these can be manipulated with STL. Combining these vectors to a dataframe for return is very

Re: [Rcpp-devel] Push back to a matrix

2011-09-05 Thread Douglas Bates
On Mon, Sep 5, 2011 at 1:11 PM, Noah Silverman wrote: > Nice, > > But, how can I copy to the Rcpp::NumericMatrix column? > > This fails: > std::vector data1; > // do stuff to populate data1 > > Rcpp::NumericMatrix output(data1.size(), 6); > std::copy(data1.begin(), data1.end(), output(_,0) ); std

Re: [Rcpp-devel] Push back to a matrix

2011-09-05 Thread Noah Silverman
Nice, But, how can I copy to the Rcpp::NumericMatrix column? This fails: std::vector data1; // do stuff to populate data1 Rcpp::NumericMatrix output(data1.size(), 6); std::copy(data1.begin(), data1.end(), output(_,0) ); I'm probably referencing the matrix column incorrectly, but can't find any

Re: [Rcpp-devel] Push back to a matrix

2011-09-05 Thread Noah Silverman
Good idea. Thank You!! -- Noah Silverman UCLA Department of Statistics 8117 Math Sciences Building #8208 Los Angeles, CA 90095 On Sep 5, 2011, at 9:46 AM, Douglas Bates wrote: > On Mon, Sep 5, 2011 at 11:31 AM, Noah Silverman > wrote: >> Hi, >> Using Rcpp through inline. >> I want to return a

Re: [Rcpp-devel] Push back to a matrix

2011-09-05 Thread Douglas Bates
On Mon, Sep 5, 2011 at 11:31 AM, Noah Silverman wrote: > 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

[Rcpp-devel] Push back to a matrix

2011-09-05 Thread Noah Silverman
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 fu