Passing by reference a data.frame and updating it with rcpp
looking at the rcpp documentation and Rcpp::DataFrame in the gallery I realized that I didn't know how to modify a DataFrame by reference. Googling a bit I found this post on SO and this post on the archive. There is nothing obvious so I suspect I miss something big like "It is already the case because" or "it does not make sense because". I tried the following which compiled but the data.frame object passed to updateDFByRef in R stayed untouched #include <Rcpp.h> using namespace Rcpp; // [[Rcpp::export]] void updateDFByRef(DataFrame& df) { int N = df.nrows(); NumericVector newCol(N,1.); df[