[Rcpp-devel] DataFrame and passing by reference

stat quant statquant at outlook.com
Sun Mar 31 15:44:07 CEST 2013

Hello list,
looking at Rcpp::DataFrame in the
gallery<http://gallery.rcpp.org/tags/dataframe/>I realized that I
didn't know how to modify a DataFrame by reference.
Googling a bit I found this post on
this post
on the archive<http://www.mail-archive.com/rcpp-devel@lists.r-forge.r-project.org/msg04919.html>
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["newCol"] = newCol;

Could somebody explain me what I am missing or kindly point me to a
document where I can find the explanation ?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20130331/1987f49c/attachment-0001.html>

More information about the Rcpp-devel mailing list