Re: [Rcpp-devel] DataFrame and passing by reference

2013-03-31 Thread stat quant
Thanks Kevin, This question came because when you do this // [[Rcpp::export]] DataFrame updateDFByValue(DataFrame df) { int N = df.nrows(); NumericVector newCol(N,1.); df["newCol"] = newCol; return(df); } The DataFrame is returned to R as a list, and building back another data.fra

Re: [Rcpp-devel] DataFrame and passing by reference

2013-03-31 Thread Kevin Ushey
I think the problem here is that the assignment df["newCol"] = newCol copies the dataframe. Note that something like this would work as expected: #include using namespace Rcpp; // [[Rcpp::export]] void updateDFByRef(DataFrame& df) { int N = df.nrows(); NumericVector newCol(N,1.); df[

[Rcpp-devel] DataFrame and passing by reference

2013-03-31 Thread stat quant
Hello list, looking at Rcpp::DataFrame in the galleryI realized that I didn't know how to modify a DataFrame by reference. Googling a bit I found this post on SO