Skip to content
Back to formatted view

Raw Message

Message-ID: <CAJJHHA9DHNKfgk8dghzbMsjrhH5JiVzZ80OPTabR592YooGntQ@mail.gmail.com>
Date: 2013-03-31T13:44:07Z
From: stat quant
Subject: [Rcpp-devel] DataFrame and passing by reference

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
SO<http://stackoverflow.com/questions/13773529/passing-a-data-table-to-c-functions-using-rcpp-and-or-rcpparmadillo>and
this post
on the archive<http://www.mail-archive.com/rcpp-devel at 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;
    return;
}

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

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