<div>Dear Rcpp developer,</div><div>  I am tried return a big DataFrame from Rcpp to R, but met some problem!</div><div><br></div><div>### begin dataframetest.cpp</div><div><br></div><div>#include <Rcpp.h></div><div>
using namespace Rcpp;</div><div>using namespace std;</div><div><br></div><div>// [[Rcpp::export]]</div><div>DataFrame dataframetest(NumericVector close){</div><div>  int nrow = close.size();</div><div>  vector<double>  txn_qty = vector<double>(nrow);</div>
<div>  vector<double> txn_prc = vector<double>(nrow);</div><div>  vector<double>  txn_fee = vector<double>(nrow);</div><div>  vector<double>  pos_qty = vector<double>(nrow);</div><div>  vector<double>  close_prc = as<vector<double> >(close);</div>
<div>  vector<double>  PL = vector<double>(nrow);</div><div>  DataFrame PLrecord = DataFrame::create(Named("txn.qty", txn_qty),</div><div><span class="Apple-tab-span" style="white-space:pre">                                        </span> Named("txn.prc", txn_prc),</div>
<div><span class="Apple-tab-span" style="white-space:pre">                                      </span> Named("txn.fee", txn_fee),</div><div><span class="Apple-tab-span" style="white-space:pre">                                        </span> Named("pos.qty", pos_qty),</div>
<div><span class="Apple-tab-span" style="white-space:pre">                                      </span> Named("close.prc", close_prc),</div><div><span class="Apple-tab-span" style="white-space:pre">                                    </span> Named("PL", PL));</div>
<div>  return PLrecord;</div><div>}</div><div>#### end  dataframetest.cpp</div><div><br></div><div>### R code </div><div>n <- 4e5</div><div>x.prc <- 1:n</div><div>library(Rcpp)</div><div>sourceCpp("./dataframetest.cpp")</div>
<div>aa <- dataframetest(x.prc)</div><div><br></div><div>##### end R code </div><div><br></div><div> When n is big, like 4e5, then it will exhaust the memory or crash; when n is small, like  4e3, it can return the correct DataFrame. I was wondering if Rcpp::DataFrame can handle so big DataFrame. In my opinion, n = 4e5 is not big, I can create such a long data.frame from R code easily, without any problem. Why Rcpp can not? Or I miss something? </div>
<div><br></div><div>### R code</div><div>n <- 4e5</div><div>x.prc <- rnorm(n)</div><div>a <- data.frame(x = x.prc, </div><div><span class="Apple-tab-span" style="white-space:pre"> </span>        y = x.prc, </div>
<div>                d = x.prc,</div><div>                e = x.prc, </div><div>                f = x.prc, </div><div>                k = x.prc)</div><div>head(a)</div><div>            x           y           d           e           f           k</div>
<div>1 -0.45145433 -0.45145433 -0.45145433 -0.45145433 -0.45145433 -0.45145433</div><div>2 -0.55851370 -0.55851370 -0.55851370 -0.55851370 -0.55851370 -0.55851370</div><div>3  0.18209145  0.18209145  0.18209145  0.18209145  0.18209145  0.18209145</div>
<div>4 -0.56092768 -0.56092768 -0.56092768 -0.56092768 -0.56092768 -0.56092768</div><div>5  0.25689622  0.25689622  0.25689622  0.25689622  0.25689622  0.25689622</div><div>6 -0.04558792 -0.04558792 -0.04558792 -0.04558792 -0.04558792 -0.04558792</div>
<div><br></div><div>#### sessionInfo</div><div>sessionInfo()</div><div>R version 2.15.3 (2013-03-01)</div><div>Platform: x86_64-suse-linux-gnu (64-bit)</div><div><br></div><div>locale:</div><div> [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              </div>
<div> [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    </div><div> [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   </div><div> [7] LC_PAPER=C                 LC_NAME=C                 </div><div> [9] LC_ADDRESS=C               LC_TELEPHONE=C            </div>
<div>[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       </div><div><br></div><div>attached base packages:</div><div>[1] stats     graphics  grDevices utils     datasets  methods   base     </div><div><br></div><div>
other attached packages:</div><div>[1] Rcpp_0.10.3      data.table_1.8.8</div><div><br></div><div>loaded via a namespace (and not attached):</div><div>[1] compiler_2.15.3 tools_2.15.3   </div><div><br></div>