[Rcpp-devel] Persistent C++ objects within R/Rcpp?

Andy Garcia andyg at ufl.edu
Mon Jun 25 22:38:41 CEST 2012


First, thank you to the Rcpp team for their work on Rcpp. It's an
incredible resource to get C++ code executing from R.

I've worked through setting up the correct development environment (Ian
Fellow's post on Eclipse + Rcpp was great with a few tweaks for a Linux
install) as well some of the examples. The next step I'd like to take is
develop some prototype code for implementing an individual-based simulation.

Let's say I have a function that creates the simulated population based on
some number of input parameters:

RcppExport SEXP CreatePopulation( /* some amount of input parameters*/ );

I would then want other functions called in R via Rcpp to operate on the
population or return specific results. The part I'm struggling with is how
would the population state persist when created in CreatePopulation to be
then access/modified in other functions. My initial though is to have some
sort of population object, however I don't know how this would persist when
the code returns from execution in C++. R can't store a C++ object to be
passed back, correct? Could I just create a global object within C++?

Any feedback would be appreciated,
Andy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20120625/210a3103/attachment.html>


More information about the Rcpp-devel mailing list