[Rcpp-devel] redimension help-my_chosen_solution

Silkworth,David J. SILKWODJ at airproducts.com
Wed Jun 8 16:59:55 CEST 2011

Thanks for all who got involved in my folly.
I have chosen the following path for now.

src <- '
int s = 7;  // result of original oversize estimate before process runs
int c=3;  //known column count established from a list argument (variable to function)
Rcpp::IntegerVector v(s);
Rcpp::IntegerMatrix m(s,c);

int r = 4;  // number of rows that more complex process found necessary to fill
for(int x=1; x<r+1;x++)  { v[x-1]=x; }  // just partial fill as process would
for(int j=0; j<r;j++)  { for(int i=0;i<r;i++)  {m(i,j)= (i+1)*(j+1);} }

Rcpp::DataFrame DF =

Rcpp::IntegerVector my_r(1);

Rcpp::List L=Rcpp::List::create(DF,my_r);
return L;

 fun <- cxxfunction(signature(),src, plugin = "Rcpp")


That is, just send it all back to R in a dataframe and let R do the clean-up.
I'm not certain how this will perform when r>120000.  This operation is only performed once though.  I also intend to develop a better estimate for s than, say 160000.

More information about the Rcpp-devel mailing list